/* ========================================================================
   common.css - 价格监控系统公共样式
   包含: CSS变量(深色模式) / 导航栏 / 按钮 / 卡片 / 表格 / 表单 / 动画
   ======================================================================== */

/* ── CSS 变量：浅色主题(默认) ── */
:root {
    --bg-body: #f5f6fa;
    --bg-card: #ffffff;
    --bg-navbar: linear-gradient(90deg, #1e1b4b 0%, #312e81 100%);
    --bg-table-header: #f8f9fc;
    --bg-input: #ffffff;
    --bg-hover: #fafbff;
    --bg-overlay: rgba(0,0,0,.4);

    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --text-faint: #aaa;
    --text-navbar: #c7d2fe;
    --text-navbar-hover: #ffffff;
    --text-navbar-active: #fb923c;

    --border-color: #e2e8f0;
    --border-light: #f0f0f0;
    --border-input: #ddd;

    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-success: #059669;
    --color-danger: #dc2626;
    --color-warning: #d97706;
    --color-info: #2563eb;
    --color-price: #e53e3e;

    --shadow-sm: 0 1px 4px rgba(0,0,0,.07);
    --shadow-md: 0 2px 10px rgba(0,0,0,.05);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.2);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --font-size: 13px;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", "Noto Sans", "Noto Sans CJK SC", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Twemoji Mozilla", emoji;

    --navbar-height: 56px;
    --navbar-height-mobile: 52px;
}

/* ── CSS 变量：深色主题 ── */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-navbar: linear-gradient(90deg, #0f172a 0%, #1e1b4b 100%);
    --bg-table-header: #1e293b;
    --bg-input: #334155;
    --bg-hover: #1e293b;
    --bg-overlay: rgba(0,0,0,.6);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --text-navbar: #c7d2fe;
    --text-navbar-hover: #ffffff;
    --text-navbar-active: #fb923c;

    --border-color: #334155;
    --border-light: #1e293b;
    --border-input: #475569;

    --color-primary: #6366f1;
    --color-primary-hover: #818cf8;
    --color-success: #34d399;
    --color-danger: #f87171;
    --color-warning: #fbbf24;
    --color-info: #60a5fa;
    --color-price: #f87171;

    --shadow-sm: 0 1px 4px rgba(0,0,0,.3);
    --shadow-md: 0 2px 10px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

/* ── 基础重置 ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: var(--font-size);
    line-height: 1.6;
}

/* ── 导航栏 ── */
.navbar {
    background: var(--bg-navbar);
    color: #fff;
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.08);
    overflow: hidden;
}
.navbar .brand {
    font-weight: 700;
    font-size: 17px;
    color: #f8fafc;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.navbar .nav-links {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: center;
    z-index: 1;
    max-width: calc(100% - 400px);
}
.navbar .nav-links::-webkit-scrollbar { display: none; }
.navbar .nav-links a {
    color: var(--text-navbar);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    white-space: nowrap;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}
.navbar .nav-links a:hover { background: rgba(255,255,255,.1); color: var(--text-navbar-hover); }
.navbar .nav-links a.active { background: rgba(251,146,60,.18); color: var(--text-navbar-active); box-shadow: inset 0 -2px 0 0 rgba(251,146,60,.6); }
.navbar .nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}
.navbar .nav-right a {
    color: var(--text-navbar);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    white-space: nowrap;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}
.navbar .nav-right a:hover { background: rgba(255,255,255,.08); color: var(--text-navbar-hover); }

/* 深色模式切换按钮 */
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,.15);
    color: var(--text-navbar);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}
.theme-toggle:hover { background: rgba(255,255,255,.08); color: var(--text-navbar-hover); }
.theme-toggle svg { display: block; }

/* 汉堡菜单 — 纯CSS checkbox方案，不依赖JS */
.nav-checkbox { display: none; }
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-navbar-hover);
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
    position: relative;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}
.nav-toggle svg { display: block; }
/* 点击空白区域关闭菜单的透明遮罩 */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9997;
    background: transparent;
}

/* ── 容器 ── */
.container { max-width: 1280px; margin: 0 auto; padding: 16px 20px; }

/* ── 统一页面标题区（各页面通用） ── */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.page-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #ff8a4c 0%, #f97316 50%, #ea580c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(234, 88, 12, .28), inset 0 1px 0 rgba(255,255,255,.25);
    transition: transform .15s, box-shadow .15s;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.page-header:hover .page-header-icon {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(234, 88, 12, .35), inset 0 1px 0 rgba(255,255,255,.25);
}
.page-header-title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    letter-spacing: -0.2px;
}
.page-header-subtitle {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
    font-weight: 500;
}

/* ── 统一卡片 ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── 统一标签页（tab-bar） ── */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0;
}
.tab-btn {
    padding: 8px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: #e64a19;
    border-bottom-color: #e64a19;
    font-weight: 600;
}
.tab-page { display: none; }
.tab-page.active { display: block; animation: pageFadeIn .25s ease-out; }

/* ── 统计栏 ── */
.stats-bar { display: flex; gap: 12px; margin-bottom: 14px; justify-content: center; }
.stat-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    flex: 1;
    max-width: 280px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform .2s, box-shadow .2s;
}
.stat-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-item .icon { font-size: 20px; }
.stat-item .info .val { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.stat-item .info .label { font-size: 11px; color: var(--text-muted); }

/* ── 工具栏 ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

/* ── 按钮 ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border-input); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-danger { background: #fee2e2; color: var(--color-danger); }
[data-theme="dark"] .btn-danger { background: rgba(220,38,38,.15); }
.btn-danger:hover { background: #fca5a5; }
.btn-success { background: #d1fae5; color: var(--color-success); }
[data-theme="dark"] .btn-success { background: rgba(5,150,105,.15); }
.btn-success:hover { background: #a7f3d0; }
.btn-warning { background: #fef3c7; color: var(--color-warning); }
[data-theme="dark"] .btn-warning { background: rgba(217,119,6,.15); }
.btn-warning:hover { background: #fde68a; }
.btn-info { background: #dbeafe; color: var(--color-info); }
[data-theme="dark"] .btn-info { background: rgba(37,99,235,.15); }
.btn-info:hover { background: #bfdbfe; }

/* 圆角操作按钮 */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 500;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1.3;
}
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    align-items: center;
}
.product-name { overflow: hidden; }
.product-name a {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.name-sub {
    font-size: 11px;
    color: var(--text-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    margin-top: 2px;
}
.btn-action.edit { background: #f1f5f9; color: #475569; }
[data-theme="dark"] .btn-action.edit { background: rgba(71,85,105,.3); color: #cbd5e1; }
.btn-action.edit:hover { background: #e2e8f0; color: #1e293b; }
.btn-action.refresh { background: #fff7ed; color: #c2410c; }
[data-theme="dark"] .btn-action.refresh { background: rgba(194,65,12,.15); color: #fb923c; }
.btn-action.refresh:hover { background: #ffedd5; }
.btn-action.copy { background: #f0fdf4; color: #15803d; }
[data-theme="dark"] .btn-action.copy { background: rgba(21,128,61,.15); color: #4ade80; }
.btn-action.copy:hover { background: #dcfce7; }
.btn-action.delete { background: #fef2f2; color: #b91c1c; }
[data-theme="dark"] .btn-action.delete { background: rgba(185,28,28,.15); color: #f87171; }
.btn-action.delete:hover { background: #fee2e2; }

/* ── 搜索框 ── */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    gap: 6px;
    flex: 1;
    max-width: 300px;
}
.search-box input {
    border: none;
    outline: none;
    padding: 5px 0;
    font-size: 12px;
    width: 100%;
    background: transparent;
    color: var(--text-primary);
}

/* ── 表格 ── */
.table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
thead tr { background: var(--bg-table-header); }
th, td { min-width: 0; }
th {
    padding: 8px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
th:first-child, td:first-child { text-align: center; }
.product-table th:nth-child(4), .product-table td:nth-child(4) { padding-left: 16px; }
th:last-child, td:last-child { text-align: right; }

/* ── 价格 ── */
.price-final { font-size: 14px; font-weight: 700; color: var(--color-price); }
.price-final.empty { color: var(--text-faint); font-size: 12px; font-weight: normal; }
.price-original { font-size: 11px; color: var(--text-faint); text-decoration: line-through; }

/* ── 状态徽章 ── */
.status-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: middle;
}
.status-active { background: #d1fae5; color: #059669; }
[data-theme="dark"] .status-active { background: rgba(5,150,105,.15); color: #34d399; }
.status-paused { background: #f3f4f6; color: #9ca3af; }
[data-theme="dark"] .status-paused { background: rgba(156,163,175,.15); color: #94a3b8; }

/* ── 抽屉 ── */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 200;
}
.drawer-overlay.open { display: block; }
.drawer {
    position: fixed;
    top: 0;
    right: -560px;
    width: 560px;
    height: 100vh;
    background: var(--bg-card);
    z-index: 201;
    transition: right .28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
}
.drawer.open { right: 0; }
.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    background: var(--bg-table-header);
}
.drawer-header h3 { flex: 1; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    padding: 0 4px;
}
.drawer-close:hover { color: var(--text-primary); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.drawer-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--bg-table-header);
}

/* ── 表单 ── */
.form-section { margin-bottom: 16px; }
.form-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.form-row.single { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
    border: 1px solid var(--border-input);
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 12px;
    outline: none;
    transition: border-color .15s;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--color-primary); }
.form-group input[readonly] { background: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; }
.form-group textarea { resize: vertical; min-height: 55px; font-family: inherit; }
.form-group .hint { font-size: 10px; color: var(--text-faint); }

/* ── 弹窗 ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:translateY(-10px) } to { opacity:1; transform:translateY(0) } }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}
.modal-header h3 { flex: 1; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── 空状态 ── */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-faint);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }
.empty-state svg { opacity: 0.3; margin-bottom: 16px; }

/* ── Toast 提示 ── */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateX(20px);
    transition: all .25s;
    max-width: 280px;
    pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-danger); }
.toast.info { border-left: 3px solid var(--color-info); }

/* ── 加载 ── */
.loading-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    z-index: 10;
}
[data-theme="dark"] .loading-overlay { background: rgba(15,23,42,.7); }
.loading-overlay.show { display: flex; }
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 骨架屏 ── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border-light) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-text { height: 12px; margin-bottom: 6px; border-radius: 4px; }
.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }

/* ── 价格变动闪烁 ── */
@keyframes priceFlashUp {
    0% { background-color: transparent; }
    20% { background-color: rgba(220,38,38,.2); }
    100% { background-color: transparent; }
}
@keyframes priceFlashDown {
    0% { background-color: transparent; }
    20% { background-color: rgba(5,150,105,.2); }
    100% { background-color: transparent; }
}
.price-flash-up { animation: priceFlashUp 1.2s ease-out; }
.price-flash-down { animation: priceFlashDown 1.2s ease-out; }

/* ── 数字滚动动画容器 ── */
.number-roll { display: inline-block; }

/* ── 页面淡入 ── */
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.page-enter { animation: pageFadeIn .3s ease-out; }

/* ── 卡片悬浮微交互 ── */
.hover-lift { transition: transform .2s, box-shadow .2s; }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* ── 获取中脉冲 ── */
.fetching-badge {
    display: inline-block;
    background: #fef3c7;
    color: #d97706;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    animation: pulse 1.5s ease-in-out infinite;
}
[data-theme="dark"] .fetching-badge { background: rgba(217,119,6,.15); color: #fbbf24; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── 分页 ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    border-top: 1px solid var(--border-light);
}
.page-btn {
    padding: 4px 9px;
    border: 1px solid var(--border-input);
    border-radius: 5px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
}
.page-btn:hover { background: var(--bg-hover); }
.page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-info { font-size: 12px; color: var(--text-faint); margin: 0 4px; }

/* ── 页脚 ── */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-faint);
    font-size: 0.9rem;
}

/* ── 监控设置栏 ── */
.settings-bar {
    background: var(--bg-table-header);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.settings-bar label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.settings-bar input[type="number"] {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid var(--border-input);
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    background: var(--bg-input);
    color: var(--text-primary);
}
.settings-bar .unit { font-size: 11px; color: var(--text-muted); }
.settings-bar .btn-save {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    margin-left: auto;
}
.settings-bar .btn-save:hover { background: var(--color-primary-hover); }

/* ── 最终价预览 ── */
.final-price-preview {
    background: linear-gradient(135deg, var(--color-primary) 0%, #7c3aed 100%);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.final-price-preview .label { font-size: 11px; opacity: 0.8; }
.final-price-preview .price { font-size: 22px; font-weight: 700; }
.final-price-preview .formula { font-size: 10px; opacity: 0.7; margin-top: 2px; }
.discount-total-preview { font-size: 11px; opacity: 0.8; text-align: right; flex: 1; }

/* ── 来源徽章 ── */
.source-badge { font-size: 9px; padding: 1px 4px; border-radius: 3px; font-weight: 600; }
.source-api { background: #dbeafe; color: #2563eb; }
.source-manual { background: #fef3c7; color: #d97706; }
[data-theme="dark"] .source-api { background: rgba(37,99,235,.15); color: #60a5fa; }
[data-theme="dark"] .source-manual { background: rgba(217,119,6,.15); color: #fbbf24; }

/* ── 响应式：手机端 ── */
@media (max-width: 768px) {
    .navbar { padding: 0 12px; height: var(--navbar-height-mobile); overflow: visible; }
    .navbar .brand { font-size: 13px; }
    .navbar .nav-links {
        display: none;
        position: fixed;
        top: var(--navbar-height-mobile);
        left: 0; right: 0;
        background: var(--bg-navbar);
        flex-direction: column;
        padding: 8px 12px;
        gap: 2px;
        transform: none;
        max-width: none;
        box-shadow: 0 4px 12px rgba(0,0,0,.3);
        z-index: 9999 !important;
    }
    /* 纯CSS checkbox方案：勾选时显示菜单 */
    .nav-checkbox:checked ~ .nav-links { display: flex; }
    /* 勾选时显示遮罩（点击空白关闭） */
    .nav-checkbox:checked ~ .nav-overlay { display: block; }
    /* 兼容旧方案 */
    .navbar .nav-links.open { display: flex; }
    .navbar .nav-links a { padding: 12px 14px; font-size: 14px; }
    .navbar .nav-right { display: none; }
    .nav-toggle { display: block; z-index: 9998 !important; }

    .container { padding: 12px 12px; }

    .stats-bar { flex-wrap: wrap; gap: 8px; }
    .stat-item { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 8px 10px; }
    .stat-item .icon { font-size: 16px; }
    .stat-item .info .val { font-size: 16px; }
    .stat-item .info .label { font-size: 10px; }

    .settings-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
    .settings-bar .btn-save { margin-left: 0; width: 100%; text-align: center; }

    .toolbar { flex-wrap: wrap; gap: 6px; }
    .toolbar .btn { padding: 6px 10px; font-size: 11px; }
    .search-box { max-width: none; flex: 1 1 100%; }
    .toolbar select { flex: 1 1 calc(50% - 3px); }

    .table-wrap { overflow-x: auto; }
    table { min-width: 720px; }
    th, td { padding: 7px 8px; font-size: 11px; }
    .btn-action { padding: 2px 5px; font-size: 10px; border-radius: 10px; gap: 2px; }
    .actions { gap: 4px; }
    .product-table th:nth-child(4), .product-table td:nth-child(4) { padding-left: 10px; }

    .drawer { width: 100%; right: -100%; }
    .drawer.open { right: 0; }
    .drawer-body { padding: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .form-row.triple { grid-template-columns: 1fr; }

    .modal { width: 95%; max-height: 95vh; }

    .toast-container { top: var(--navbar-height-mobile); right: 12px; left: 12px; }
    .toast { max-width: none; }

    /* ── 768px 补充：page-header / tab-bar / card 移动端适配 ── */
    .page-header { gap: 8px; margin-bottom: 14px; }
    .page-header-icon { width: 36px; height: 36px; font-size: 18px; border-radius: 8px; }
    .page-header-title { font-size: 16px; }
    .page-header-subtitle { font-size: 11px; }

    .tab-bar { overflow-x: auto; scrollbar-width: none; gap: 0; }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab-btn { padding: 8px 14px; font-size: 13px; white-space: nowrap; }

    .card { padding: 14px; margin-bottom: 12px; }
    .card-title { font-size: 13px; margin-bottom: 12px; }

    .search-box { max-width: none; }
    .btn { padding: 6px 12px; font-size: 11px; }
}

/* ── 响应式：超小屏手机（<=480px） ── */
@media (max-width: 480px) {
    .container { padding: 10px 8px; }

    .stats-bar { flex-direction: column; gap: 6px; }
    .stat-item { flex: 1 1 100%; padding: 8px 10px; }

    .navbar .brand { font-size: 12px; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 6px; }
    .page-header-icon { width: 32px; height: 32px; font-size: 16px; }
    .page-header-title { font-size: 15px; }

    .card { padding: 10px; border-radius: 8px; }

    .tab-btn { padding: 7px 10px; font-size: 12px; }

    table { min-width: 600px; }
    th, td { padding: 6px 6px; font-size: 10px; }

    .drawer-body { padding: 10px; }
    .modal { width: 100%; border-radius: 0; max-height: 100vh; }

    .toast { font-size: 11px; padding: 8px 12px; }

    .btn { padding: 5px 10px; font-size: 11px; }
    .btn-action { padding: 2px 4px; font-size: 9px; }

    .final-price-preview { padding: 10px 12px; }
    .final-price-preview .price { font-size: 18px; }
}
