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

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --success: #0d904f;
    --warning: #f9ab00;
    --danger: #ea4335;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #202124;
    --text-secondary: #5f6368;
    --border: #dadce0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    /* 表头吸附高度：顶部导航(header 56px) + tab 导航高度，由 JS 动态补偿 */
    --sticky-table-top: 106px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ==================== Login Page ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.login-logo .logo-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--text);
    font-weight: 700;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

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

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 0.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
    text-align: center;
}

#loginBtn2 {
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
}

.login-footer {
    margin-top: 24px;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
}

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

/* Header（第一层：深蓝品牌层） */
.app-header {
    background: #0C447C;
    color: white;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

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

.header-left .app-icon {
    font-size: 24px;
}

.header-left h1 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.header-left .brand-sub {
    display: block;
    font-size: 10px;
    color: rgba(255,255,255,0.75);
    line-height: 1.2;
    letter-spacing: .5px;
}

.header-right {
    display: flex;
    align-items: center;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 4px 12px 4px 4px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.2s;
}

.user-dropdown-btn .user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #B5D4F4;
    color: #0C447C;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.user-dropdown-btn:hover {
    background: rgba(255,255,255,0.25);
}

.dropdown-arrow {
    font-size: 10px;
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: white;
    border: 0.5px solid var(--border);
    border-radius: var(--border-radius-md);
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 200;
    overflow: hidden;
}

.user-dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-primary, #333);
    cursor: pointer;
    border-bottom: 0.5px solid var(--border);
    transition: background 0.15s;
}

.dropdown-item:last-child {
    border-bottom: none;
    color: #e53935;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

/* ==================== Tab Navigation ==================== */
.tab-nav {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 56px;
    z-index: 99;
}

.tab-btn {
    flex: 1;
    padding: 14px 12px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}

.tab-content {
    display: none;
    flex: 1;
}

.tab-content.active {
    display: block;
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    padding: 12px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
}

.card-body {
    padding: 16px;
}

/* ==================== Search Section ==================== */
.search-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.search-row {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    z-index: 100;
}

.search-input-wrapper input {
    width: 100%;
    padding: 10px 12px;
    padding-right: 32px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
}

.search-history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-history-dropdown.show {
    display: block;
}

.search-history-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-history-item:hover {
    background: var(--primary-light);
}

.search-history-item .history-icon {
    font-size: 12px;
    opacity: 0.5;
}

/* ==================== Product Search Results ==================== */
.product-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.product-search-results.show {
    display: block;
}

.product-search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-search-item:hover {
    background: var(--primary-light);
}

.product-search-item .prod-info {
    flex: 1;
}

.product-search-item .prod-name {
    font-weight: 500;
    font-size: 13px;
}

.product-search-item .prod-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.product-search-item .memory-badge {
    font-size: 10px;
    background: #fef3e0;
    color: #e67e22;
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

/* 库存为0红底提示（仅视觉标识，不影响勾选/提交） */
.product-search-item.product-out-stock {
    background: #fdecea;
    border: 1px solid #f5c6c6;
    border-radius: 6px;
}
.product-search-item.product-out-stock .prod-name {
    color: #b71c1c;
}
.product-search-item.product-out-stock .prod-meta {
    color: #c62828;
}
.out-stock-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #c62828;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    vertical-align: middle;
}

.prod-add-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0.5px solid var(--primary);
    background: var(--primary);
    color: white;
    font-size: 16px;
    line-height: 26px;
    text-align: center;
    flex-shrink: 0;
    cursor: pointer;
    margin-left: 8px;
}

.product-check-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-top: 0.5px solid var(--border);
    background: #fafafa;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.product-check-bar span {
    font-size: 12px;
    color: var(--text-secondary);
}

.batch-add-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

/* ==================== Order Form ==================== */
.order-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.order-panel .panel-title {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-panel .panel-title .product-badge {
    font-size: 12px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 400;
}

.order-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px;
}

@media (max-width: 480px) {
    .order-form-grid {
        grid-template-columns: 1fr;
    }
}

.order-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-field label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.order-field input {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    background: white;
}

.order-field input:focus {
    border-color: var(--primary);
}

.order-field input.readonly {
    background: #f8f9fa;
    color: var(--text-secondary);
}

.order-field .unit {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Toggle Switch for in-transit */
.toggle-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-label {
    font-size: 13px;
    font-weight: 500;
}

.toggle-label.active {
    color: var(--primary);
}

/* Suggested order section */
.suggested-order-box {
    margin: 0 16px 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #e8f0fe, #f0f7ff);
    border-radius: var(--radius);
    border: 2px solid var(--primary-light);
}

.suggested-order-box .so-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.suggested-order-box .so-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.suggested-order-box .so-formula {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Confirm order section — 同行排列: 确认订单量 + 使用建议量按钮 */
.confirm-order-section {
    padding: 0 16px 16px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.confirm-order-section .order-field {
    flex: 1;
    min-width: 0;
}
.confirm-order-section .order-field input {
    width: 100%;
    padding: 8px 10px;
}
.confirm-order-section .use-suggested-btn {
    flex-shrink: 0;
    white-space: nowrap;
    align-self: flex-end;
}

/* ==================== Buttons (柔和轻质感) ==================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(26,115,232,0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 3px 10px rgba(26,115,232,0.35);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 2px 6px rgba(15,127,68,0.25);
}

.btn-success:hover {
    background: #0b7a3e;
    box-shadow: 0 3px 10px rgba(15,127,68,0.35);
}

.btn-outline {
    background: white;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.btn-outline:hover {
    background: var(--primary-light);
    box-shadow: 0 3px 8px rgba(0,0,0,0.10);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 6px rgba(234,67,53,0.25);
}

.btn-danger:hover {
    background: #c62828;
    box-shadow: 0 3px 10px rgba(234,67,53,0.35);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 18px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==================== Table ==================== */
.data-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 60vh;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
.data-table th {
    background: #E8EFF7;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #2C2C2A;
    border-bottom: 1px solid #D7E3F0;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

/* 订单记录/数据模块：表头整页滚动吸附在顶部导航下方（不再容器内滚动） */
.data-table-wrapper.sticky-scroll-table {
    overflow: visible;
    max-height: none;
}
.data-table-wrapper.sticky-scroll-table .data-table {
    width: 100%;
}
.data-table-wrapper.sticky-scroll-table .data-table thead th {
    position: sticky;
    top: var(--sticky-table-top);
    z-index: 30;
    background: #E8EFF7;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table tbody tr:nth-child(even) td { background: #FAFCFE; }
.data-table tbody tr:hover td { background: #F0F6FC; }
.data-table td.num { font-weight: 700; }

/* 日均销售：当日数量达「近7天日均3倍」→ 整行浅红底（优先级高于斑马纹/悬停，避免覆盖） */
.data-table tbody tr.daily-sales-red td {
    background: #fdecea !important;
}
.data-table tbody tr.daily-sales-red:hover td {
    background: #fbdcd9 !important;
}

/* ==================== Modal ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    padding: 12px 24px;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #333; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==================== Loading ==================== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ==================== Order Items List ==================== */
.order-items-list {
    padding: 0 16px 16px;
    max-height: 400px;
    overflow-y: auto;
}

.order-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 8px;
}

.order-item-row .item-info {
    flex: 1;
    min-width: 0;
}

.order-item-row .item-name {
    font-weight: 500;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-item-row .item-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.order-item-row .item-qty {
    font-weight: 600;
    font-size: 16px;
    color: var(--primary);
    white-space: nowrap;
}

.order-item-row .item-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

/* ==================== Management Page ==================== */
/* 统一组件规范：下划线式 Tab（全系统一致，PC 单行可横向滚动） */
.mgmt-tabs {
    display: flex;
    gap: 6px;
    padding: 0 12px;
    flex-wrap: wrap;        /* 按钮多时自动换行（PC/移动端一致），避免最后按钮溢出不可见 */
    row-gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.mgmt-tabs::-webkit-scrollbar { display: none; }

.mgmt-tab {
    position: relative;
    padding: 12px 14px;
    background: transparent;
    border: none;
    font-size: 13px;
    color: #8895A6;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
    min-width: 72px;
    text-align: center;
    transition: color .2s;
}
.mgmt-tab::after {
    content: '';
    position: absolute;
    left: 18%;
    right: 18%;
    bottom: -1px;
    height: 2.5px;
    border-radius: 2px 2px 0 0;
    background: transparent;
    transition: background .2s;
}
.mgmt-tab:hover { color: #185FA5; }

.mgmt-tab.active {
    color: #185FA5;
    font-weight: 700;
    box-shadow: none;
}
.mgmt-tab.active::after { background: #378ADD; }

/* 数据页说明文字弱化 */
.hint-text {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: .75;
    padding: 0 12px 6px;
}
/* 「可左右滑动」提示 */
.swipe-hint {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    padding: 2px 0 4px;
    opacity: .7;
}
/* 数量加粗突出 */
.data-table td.num { font-weight: 700; }

/* ==================== 微信内置浏览器兼容 ==================== */
/* iOS 微信 WebView 对 sticky 支持差异：补 -webkit- 前缀 */
.wechat #transitTable .sticky-status,
.wechat #transitTable td.status-cell,
.wechat .data-table thead { position: -webkit-sticky; }
/* 防 iOS 微信自动放大：表单控件字号 >= 16px */
.wechat input[type="text"],
.wechat input[type="number"],
.wechat input[type="date"],
.wechat input[type="search"],
.wechat select { font-size: 16px; }
/* 去除点击 300ms 延迟/双击缩放 */
.wechat .btn, .wechat .tab-btn, .wechat .mgmt-tab,
.wechat input, .wechat select, .wechat .prod-name-fold {
    touch-action: manipulation;
}
/* 微信内表格滚动容器惯性滚动 */
.wechat .data-table-wrapper,
.wechat .mgmt-tabs { -webkit-overflow-scrolling: touch; }
/* 微信地址栏高度差异：页面底部留白 */
.wechat .app-container { padding-bottom: env(safe-area-inset-bottom, 12px); }
/* 微信内数字输入防缩放 */
.wechat input[type="number"] { -webkit-appearance: none; -moz-appearance: textfield; }

/* 最近同步时间横幅（表头上方居中） */
.update-time-banner {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 6px 12px 2px;
    opacity: .9;
}
.update-time-banner .upd-time { font-weight: 600; color: var(--primary); }
.update-time-banner.upd-empty { color: #b45309; opacity: .8; }

/* ==================== 统一组件规范（全系统复用） ==================== */
/* 筛选卡片 */
.filter-card {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: #F9FBFE;
    border: 0.5px solid #E3ECF6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}
.filter-card input[type="text"],
.filter-card input[type="search"],
.filter-card select,
.filter-card input[type="date"] {
    height: 34px;
    padding: 0 10px;
    border: 0.5px solid #D7E3F0;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #2C2C2A;
    outline: none;
}
.filter-card input:focus, .filter-card select:focus { border-color: #378ADD; }
.filter-card .f-label { font-size: 12px; color: #5F6B7A; white-space: nowrap; }

/* 按钮三级：主（蓝填充）/ 次（白底蓝边）/ 危（红字） */
.btn-danger-text {
    background: none;
    border: none;
    color: #A32D2D;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.btn-danger-text:hover { background: #FCEBEB; }
.btn-danger-text:disabled { opacity: .45; cursor: not-allowed; }
.btn-link {
    background: none;
    border: none;
    color: #185FA5;
    font-size: 12.5px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 5px;
    white-space: nowrap;
}
.btn-link:hover { background: #E6F1FB; }
.btn-link.danger { color: #A32D2D; }
.btn-link.danger:hover { background: #FCEBEB; }

/* 表格行操作列（编辑/删除文字按钮组） */
.row-ops { display: flex; gap: 2px; align-items: center; white-space: nowrap; }

/* 折叠/展开产品名：最大化展示 + CSS 单行省略（宽度自适应，绝不溢出列） */
.prod-name-fold {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 8px 4px;
    margin: -6px 0;
    border-radius: 4px;
    vertical-align: bottom;
    transition: background-color .15s ease, color .15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.prod-name-fold .fold-text {
    min-width: 0;
    word-break: break-all;
    white-space: normal;   /* 展开态默认换行（折叠态由 .prod-folded 覆盖为 nowrap） */
}
.prod-name-fold.prod-folded .fold-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.prod-name-fold .fold-arrow {
    color: #888;
    font-size: 11px;
    flex: 0 0 auto;
    margin-left: 2px;
}
.prod-name-fold:active { background: rgba(55,138,221,.10); }
@media (max-width: 600px) {
    .prod-name-fold { padding: 12px 4px; margin: -10px 0; }
}

/* 状态标签 */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.tag-blue   { background: #E6F1FB; color: #185FA5; }
.tag-green  { background: #EAF3DE; color: #3B6D11; }
.tag-red    { background: #FCEBEB; color: #A32D2D; }
.tag-amber  { background: #FAEEDA; color: #854F0B; }
.tag-gray   { background: #F1EFE8; color: #5F6E5A; }
.tag-blue-solid { background: #378ADD; color: #fff; }

/* 分页组件 */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: #5F6B7A;
    flex-wrap: wrap;
}
.pagination .page-info { margin-right: auto; }
.pagination .page-btn {
    min-width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 0.5px solid #D7E3F0;
    background: #fff;
    color: #5F6B7A;
    cursor: pointer;
    font-size: 12px;
    padding: 0 8px;
}
.pagination .page-btn:hover:not(:disabled):not(.active) { border-color: #378ADD; color: #185FA5; }
.pagination .page-btn.active { background: #378ADD; color: #fff; border-color: #378ADD; font-weight: 500; }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }
.pagination select {
    height: 28px;
    border: 0.5px solid #D7E3F0;
    border-radius: 6px;
    font-size: 12px;
    padding: 0 6px;
    background: #fff;
}

/* 消息卡片（成功/失败/警告） */
.msg-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 12.5px;
    line-height: 1.55;
}
.msg-card .msg-title { font-weight: 500; margin-bottom: 2px; }
.msg-card.success { background: #EAF3DE; border: 0.5px solid #C0DD97; color: #27500A; }
.msg-card.error   { background: #FCEBEB; border: 0.5px solid #F7C1C1; color: #791F1F; }
.msg-card.warning { background: #FAEEDA; border: 0.5px solid #FAC775; color: #633806; }

/* 空状态组件 */
.empty-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 44px 16px;
    text-align: center;
}
.empty-box .empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #E6F1FB;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #378ADD;
    margin-bottom: 12px;
}
.empty-box .empty-title { font-size: 14px; font-weight: 500; color: #2C2C2A; margin-bottom: 6px; }
.empty-box .empty-tip { font-size: 12px; color: #8895A6; margin-bottom: 14px; max-width: 320px; }
.empty-box .empty-btn { display: flex; gap: 8px; }

/* 表头信息行（左提示右计数） */
.table-info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 12px 6px;
    gap: 8px;
}
.table-info-row .t-hint { font-size: 11px; color: #8895A6; }
.table-info-row .t-count { font-size: 13px; font-weight: 500; color: #2C2C2A; }


.mgmt-content {
    display: none;
    padding: 0 12px 12px;
}

.mgmt-content.active {
    display: block;
}

.mgmt-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* File upload */
.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.file-upload-label input[type="file"] {
    display: none;
}

/* ==================== Order Record Page ==================== */
.record-filters {
    display: flex;
    gap: 8px;
    padding: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.record-filters select, .record-filters input {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    outline: none;
}

/* ==================== Inline Edit ==================== */
.inline-edit-input {
    width: 80px;
    padding: 6px 8px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

/* ==================== 自定义「月/日」日期控件 ==================== */
.md-date-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.md-date-input {
    width: 100px;
    height: 34px;
    padding: 0 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    background: var(--bg-card);
    outline: none;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
}
.md-date-input::placeholder { color: var(--text-tertiary); }
.md-date-input:focus { border-color: var(--primary); }

/* 弹出面板：月/日 日历 */
.md-date-popup {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 210;
    width: 240px;
    background: #fff;
    border: 0.5px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 10px;
    box-sizing: border-box;
}
.md-date-popup.open { display: block; }

.md-cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.md-cal-head .md-cal-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}
.md-cal-nav {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
}
.md-cal-nav:active { background: var(--primary); color: #fff; }

.md-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.md-cal-grid .md-cal-weekday {
    text-align: center;
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 2px 0;
}
.md-cal-day {
    height: 30px;
    border: none;
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    line-height: 30px;
}
.md-cal-day:hover { background: var(--primary-light); color: var(--primary); }
.md-cal-day.md-cal-today {
    border: 1px solid var(--primary);
    color: var(--primary);
    font-weight: 500;
}
.md-cal-day.md-cal-sel {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}

/* 可销天数提醒 */
.sellable-days-box {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 8px 0;
    font-size: 13px;
    color: #1565c0;
}
@media print {
    .app-header, .tab-nav, .search-section, .btn { display: none; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ==================== mobile responsive ==================== */
@media (max-width: 600px) {
    .app-header { padding: 0 10px; }
    .app-header h1 { font-size: 14px; }
    .app-header .brand-sub { font-size: 9px; }
    /* 移动端账号折叠为头像 */
    .user-dropdown-btn .user-name { display: none; }
    .user-dropdown-btn { padding: 3px; }
    .user-dropdown-btn .dropdown-arrow { display: none; }
    .tab-btn { font-size: 13px; padding: 10px 8px; }
    .main-content { padding: 8px; }
    .card-body { padding: 10px; }
    
    /* 移动端表头吸附高度：header 56 + 移动端 tab-nav 约34 */
    :root { --sticky-table-top: 90px; }
    /* 表格横向滚动 */
    .data-table { font-size: 11px; }
    .data-table th, .data-table td { padding: 6px 8px; }

    /* 数据页表格：恢复横向滚动确保信息完整；窄屏压缩列宽减少滚动 */
    .data-table-wrapper { overflow-x: auto; max-height: none; }
    /* 订单记录/数据模块：整页滚动表头吸附（移动端 top 更小：header 56 + tab 约34） */
    .data-table-wrapper.sticky-scroll-table { overflow: visible; max-height: none; }
    .data-table-wrapper.sticky-scroll-table .data-table { max-height: none; width: 100%; }
    .data-table-wrapper.sticky-scroll-table .data-table thead th {
        position: sticky;
        top: var(--sticky-table-top);
        z-index: 30;
        background: #E8EFF7;
        font-weight: 600;
        white-space: nowrap;
        word-break: normal;
        box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    }
    .data-table { table-layout: auto; min-width: 0; }
    .data-table th, .data-table td {
        word-break: break-all;
        white-space: normal;
        padding: 5px 6px;      /* 收窄内边距，压缩列间距 */
    }
    .data-table td.num { white-space: nowrap; }


    /* 日期列：月/日短格式，无需折叠 */
    .data-table .col-date { white-space: nowrap; }
    /* 日期输入框加宽 */
    .mgmt-actions input[type="date"] { min-width: 110px; }

    /* 管理子标签：flex-wrap 自动换行（两行间距10px、min-width 防文字挤压） */
    .mgmt-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
        row-gap: 10px;
        padding: 6px 10px 0;
    }
    .mgmt-tab { min-width: 72px; flex: 1 1 auto; padding: 10px 8px; font-size: 12px; }
    .mgmt-actions { gap: 4px; }
    .mgmt-actions .btn { font-size: 11px; padding: 4px 8px; }

    /* 筛选卡片移动端：输入框100%宽、按钮自动换行 */
    .filter-card { padding: 10px; gap: 6px; }
    .filter-card input[type="text"],
    .filter-card input[type="search"],
    .filter-card select,
    .filter-card input[type="date"] { flex: 1 1 100%; height: 34px; }
    .filter-card .btn { flex: 1 1 auto; }
    /* 数据模块日期筛选：起止日期对保持单行，不被100%宽强制换行 */
    .filter-card input[type="date"].f-date { flex: 0 0 auto; }
    /* 订单记录筛选 */
    .record-filters select, .record-filters input { width: 100%; }
    /* 订单记录日期筛选：单行展示，不被100%宽强制换行 */
    .record-date-range { flex: 0 0 auto; white-space: nowrap; }
    .record-date-range .md-date-input { width: 96px !important; flex: 0 0 auto; height: 34px; }
    .record-date-range span { flex: none; }
    .md-date-wrap { position: relative; display: inline-flex; }
    
    /* 搜索区域 */
    .search-section { flex-direction: column; }
    .search-row { min-width: 100%; }
    
    /* 弹窗 */
    .modal { max-width: 95vw; max-height: 85vh; }
    
    /* 订货表单 */
    .order-form-grid { grid-template-columns: 1fr; gap: 8px; }
    .suggested-order-box .so-value { font-size: 24px; }

    /* 搜索框移动优化 */
    .search-input-wrapper input {
        font-size: 16px !important;
        padding: 10px 32px 10px 12px !important;
    }
    .search-history-dropdown {
        max-height: 40vh;
        z-index: 999 !important;
    }
    #productResults.search-history-dropdown {
        z-index: 999 !important;
        max-height: 40vh;
    }

    /* 门店信息栏 */
    #currentStoreName { font-size: 14px; }
    #inTransitBadge, #promoBadge { font-size: 10px; padding: 2px 6px; }
    #inTransitToggle { font-size: 11px; padding: 3px 8px; }

    /* 可销天数框 */
    .sellable-days-box { font-size: 12px; padding: 8px; }

    /* 订货卡片紧凑 */
    .order-item-card { margin: 8px 0; padding: 10px; }
    .order-item-card .order-form-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .so-value { font-size: 22px; }
    .confirm-order-section { gap: 6px; flex-wrap: wrap; }

    /* 底部导航 */
    .tab-nav { gap: 0; }
    .tab-btn { font-size: 12px; padding: 8px 4px; flex: 1; }

    /* 表格优化 */
    .data-table td, .data-table th { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* 日均销售信息区（删除提示后）：窄屏下信息组/分页组紧凑且有间隙，超出允许换行 */
    .table-info-row .sales-info-group { flex-wrap: wrap; }
    .table-info-row .sales-divider { display: none; }
}
