/* ============================================================
   在线售卖站 · 后台样式（基础风格复用自 download-station，macOS 视觉语言）
   ============================================================ */

@font-face { font-family: "LINE Seed JP"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/LINESeedJP_TTF_Rg.ttf") format("truetype"); }
@font-face { font-family: "LINE Seed JP"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/LINESeedJP_TTF_Bd.ttf") format("truetype"); }
:root {
    --bg: #e8ecf1;
    --sidebar-bg: rgba(245,245,247,0.74);
    --card-bg: rgba(255,255,255,0.84);
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #aeaeb2;
    --border: rgba(0,0,0,0.06);
    --border-strong: rgba(0,0,0,0.1);
    --accent: #007AFF;
    --accent-hover: #0062CC;
    --accent-light: rgba(0,122,255,0.1);
    --danger: #FF3B30;
    --danger-hover: #D63029;
    --success: #34C759;
    --sidebar-width: 220px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "LINE Seed JP", "Hiragino Maru Gothic ProN", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg); color: var(--text); min-height: 100vh;
    -webkit-font-smoothing: antialiased; display: flex;
}
a { color: var(--accent); text-decoration: none; }
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 16px; border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; font-weight: 500;
    cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: rgba(0,0,0,0.04); color: var(--text); }
.btn-ghost:hover { background: rgba(0,0,0,0.08); }
.btn-icon { width: 34px; padding:0; justify-content: center; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); height: 100vh; position: fixed; left:0; top:0;
    background: var(--sidebar-bg); backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 50; padding: 0 12px;
}
.sidebar-header { padding: 28px 10px 20px; display: flex; align-items: center; gap: 10px; }
.sidebar-header .logo {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 8px;
}
.sidebar-header .title { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.sidebar-nav { flex:1; position: relative; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-bottom: 8px; }
.sidebar-section-label { font-size: 10px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.8px; padding: 12px 10px 6px; }
.nav-highlight {
    position: absolute; left: 0; width: 100%; height: 34px; border-radius: var(--radius-sm);
    background: rgba(0,122,255,0.12);
    transition: transform 0.35s cubic-bezier(0.25,0.1,0.25,1), opacity 0.25s ease;
    pointer-events: none; z-index: 0;
}
.nav-item {
    position: relative; z-index: 1;
    display: flex; align-items: center; gap: 10px; padding: 7px 10px;
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 450;
    color: var(--text); cursor: pointer; border:0; background:0; font-family:inherit;
    transition: color 0.3s ease, font-weight 0.3s ease; text-align: left; width: 100%;
}
.nav-item:hover { color: var(--accent); }
.nav-item.active { color: var(--accent); font-weight: 550; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink:0; transition: transform 0.25s ease; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { transform: scale(1.1); }
.nav-item .nav-badge { margin-left: auto; font-size: 11px; color: var(--text-tertiary); }
.nav-item.active .nav-badge, .nav-item:hover .nav-badge { color: var(--accent); opacity:0.6; }
.nav-sub { max-height: 0; overflow: hidden; transition: max-height 0.35s cubic-bezier(0.25,0.1,0.25,1), opacity 0.3s ease, padding 0.35s cubic-bezier(0.25,0.1,0.25,1); display: flex; flex-direction: column; gap: 1px; padding: 0; opacity: 0; }
.nav-sub.expanded { max-height: 600px; padding: 2px 0; opacity: 1; }
.nav-sub-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px 5px 38px; border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 400; font-family: inherit;
    color: var(--text-secondary); cursor: pointer; border: 0; background: 0;
    text-align: left; width: 100%; transition: all var(--transition); white-space: nowrap;
}
.nav-sub-item:hover { color: var(--accent); background: rgba(0,122,255,0.04); }
.nav-sub-item.active { color: var(--accent); font-weight: 550; background: rgba(0,122,255,0.08); }
.sidebar-footer { padding: 12px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

/* Main */
.main { margin-left: var(--sidebar-width); flex:1; min-height: 100vh; padding: 32px 36px; max-width: calc(100vw - var(--sidebar-width)); }
.main-content-wrap { animation: contentFadeIn 0.35s cubic-bezier(0.25,0.1,0.25,1); }
@keyframes contentFadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
.titlebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.titlebar h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

/* Dashboard Stats */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
}
.stat-card .stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-top: 2px; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* Dashboard Panels */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.panel {
    background: var(--card-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.panel-full { grid-column: 1 / -1; }
.panel-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 12px 0; }
.panel-row {
    display: flex; align-items: center; padding: 8px 18px; gap: 12px;
    border-bottom: 1px solid var(--border); font-size: 13px;
}
.panel-row:last-child { border-bottom: none; }
.panel-row .pr-icon { width: 28px; text-align: center; font-size: 16px; flex-shrink: 0; }
.panel-row .pr-name { flex:1; min-width:0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-row .pr-meta { font-size: 12px; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; text-align: right; }
.panel-row .pr-bar-wrap { flex:1; height: 6px; background: rgba(0,0,0,0.06); border-radius: 3px; overflow: hidden; margin: 0 12px; }
.panel-row .pr-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.5s ease; }

/* Category Breakdown */
.cat-table { width: 100%; border-collapse: collapse; }
.cat-table th { text-align: left; padding: 8px 18px; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; border-bottom: 1px solid var(--border-strong); }
.cat-table td { padding: 10px 18px; font-size: 13px; border-bottom: 1px solid var(--border); }
.cat-table tr:last-child td { border-bottom: none; }
.cat-table .cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.cat-table .ct-num { text-align: right; font-weight: 550; }

/* File list (same as before) */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.search-field { flex:1; min-width: 200px; max-width: 420px; position: relative; }
.search-field .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.search-field input {
    width: 100%; height: 36px; padding: 0 36px 0 34px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit;
    background: var(--card-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    color: var(--text); outline: none; transition: all var(--transition);
}
.search-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); background: #fff; }
.search-field input::placeholder { color: var(--text-tertiary); }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border: none; border-radius: 50%; background: var(--text-tertiary); color: #fff; font-size: 11px; cursor: pointer; display: none; align-items: center; justify-content: center; }
.search-clear.visible { display: flex; opacity:0.7; }
.search-clear:hover { opacity:1; }

/* Sub-filter chips */
.sub-filter { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.sub-filter-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }
.sub-chip {
    display: inline-flex; align-items: center; gap: 4px;
    height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 13px;
    font-size: 12px; font-family: inherit; font-weight: 450; cursor: pointer;
    background: var(--card-bg); color: var(--text-secondary);
    transition: all var(--transition); white-space: nowrap;
}
.sub-chip:hover { border-color: var(--accent); color: var(--accent); }
.sub-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 550; }
.sub-chip .sub-chip-count { opacity: 0.6; font-size: 11px; }

/* File group header */
.file-group-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 18px; font-size: 12px; font-weight: 600; color: var(--text-secondary);
    background: rgba(0,0,0,0.02); border-top: 1px solid var(--border);
}
.file-group-header:first-child { border-top: none; }
.file-group-header .fgh-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.file-group-header .fgh-count { font-weight: 450; opacity: 0.7; }

.badge { font-size: 12px; font-weight: 550; color: var(--text-secondary); background: rgba(0,0,0,0.04); padding: 3px 10px; border-radius: 20px; }
.file-list { background: var(--card-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.file-list-header { display: flex; align-items: center; padding: 10px 18px; gap: 12px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; }
.flh-icon { width: 36px; } .flh-name { flex:1; } .flh-size { width: 100px; text-align:right; } .flh-date { width: 110px; text-align:right; } .flh-actions { width: 150px; text-align:right; }
.file-item { display: flex; align-items: center; padding: 0 18px; gap: 12px; height: 48px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: rgba(0,0,0,0.02); }
.fi-icon { width: 36px; display: flex; align-items: center; justify-content: center; }
.fi-icon svg { width: 28px; height: 28px; }
.fi-icon img.fi-vivid { width: 28px; height: auto; }
.fi-icon img.fi-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.fi-name { flex:1; min-width: 0; }
.fi-name-text { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-size { width: 100px; text-align:right; font-size: 12px; color: var(--text-secondary); }
.fi-date { width: 110px; text-align:right; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.fi-actions { width: 150px; text-align:right; display: flex; gap:6px; justify-content: flex-end; }
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 20px; }
.pagination button, .pagination span {
    min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; background: var(--card-bg);
    border: 1px solid var(--border); color: var(--text); cursor: pointer;
}
.pagination button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }
.empty-state { text-align: center; padding: 64px 24px; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity:0.6; }
.empty-state .empty-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty-state .empty-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }

.error-banner { padding: 14px 18px; margin: 16px 0; border-radius: var(--radius); background: rgba(255,59,48,0.08); color: #D32F2F; font-size: 14px; font-weight: 500; border-left: 3px solid #FF3B30; line-height: 1.5; white-space: pre-wrap; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset:0; z-index: 200; background: rgba(0,0,0,0.3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal {
    background: rgba(255,255,255,0.96); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-radius: 14px; width: 90%; max-width: 480px;
    box-shadow: var(--shadow-lg); border: 1px solid rgba(0,0,0,0.08);
    animation: modalIn 0.25s cubic-bezier(0.25,0.1,0.25,1);
}
@keyframes modalIn { from { opacity:0; transform: translateY(20px) scale(0.96); } to { opacity:1; transform: translateY(0) scale(1); } }
.modal-header { padding: 18px 20px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; border: none; border-radius: 50%; background: rgba(0,0,0,0.06); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 20px; }
.upload-progress { margin-top: 16px; max-height: 220px; overflow-y: auto; }
.upload-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.ui-name { flex:1; min-width:0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-status { font-size: 12px; flex-shrink:0; }
.upload-item.ok .ui-status { color: var(--success); }
.upload-item.fail .ui-status { color: var(--danger); }
.upload-item progress { vertical-align: middle; accent-color: var(--primary); }

/* Chart bars */
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 0 18px 12px; }
.chart-bar-wrap { flex:1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar { width: 100%; max-width: 32px; border-radius: 4px 4px 0 0; background: var(--accent); min-height: 2px; transition: height 0.5s ease; }
.chart-bar-label { font-size: 10px; color: var(--text-tertiary); white-space: nowrap; }

.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    padding: 10px 20px; border-radius: 20px;
    background: rgba(30,30,30,0.9); color: #fff;
    font-size: 13px; font-weight: 500; z-index: 400;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    animation: toastIn 0.3s ease, toastOut 0.3s 2.2s ease forwards; pointer-events: none;
}
@keyframes toastIn  { from { opacity:0; transform: translateX(-50%) translateY(-10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { to { opacity:0; transform: translateX(-50%) translateY(-10px); } }

/* Download progress bar */
.download-bar {
    display: none;
    position: fixed; bottom: 0; left: var(--sidebar-width); right: 0;
    height: 3px; z-index: 300;
}
.download-bar.active { display: block; }
.download-bar-track {
    width: 100%; height: 100%;
    background: rgba(0,122,255,0.08);
    position: relative; overflow: hidden;
}
.download-bar-indicator {
    position: absolute; top: 0; height: 100%;
    width: 28%;
    background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
    border-radius: 2px;
    animation: downloadShuttle 1.6s cubic-bezier(0.45,0,0.55,1) infinite alternate;
}
@keyframes downloadShuttle {
    from { left: -28%; }
    to { left: 100%; }
}

/* Delete confirm dialog */
.confirm-dialog {
    background: rgba(255,255,255,0.96); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-radius: 16px; width: 90%; max-width: 400px;
    box-shadow: var(--shadow-lg); border: 1px solid rgba(0,0,0,0.08);
    padding: 28px 24px 20px;
    animation: confirmIn 0.35s cubic-bezier(0.22,0.61,0.36,1);
    display: flex; flex-direction: column; gap: 20px;
}
@keyframes confirmIn {
    from { opacity: 0; transform: scale(0.88) translateY(24px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.confirm-body {
    display: flex; align-items: center; gap: 16px;
}
.confirm-icon-wrap {
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.confirm-icon-wrap svg {
    width: 56px; height: 56px;
}
.confirm-text { flex: 1; }
.confirm-text .confirm-title {
    font-size: 22px; font-weight: 500; color: var(--text);
    margin-bottom: 4px;
}
.confirm-text .confirm-desc {
    font-size: 16px; color: var(--text-secondary);
    line-height: 1.4;
}
.confirm-actions {
    display: flex; justify-content: flex-end; gap: 8px;
}

/* 订单记录表格 */
.orders-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.orders-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; padding: 10px 8px; border-bottom: 1px solid var(--border-strong); }
.orders-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); color: var(--text); }
.orders-table tr:last-child td { border-bottom: none; }
.orders-table .badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px; display: inline-block; }

.lang-switch {
    display: inline-flex; align-items: center; gap: 4px;
    height: 28px; padding: 0 10px;
    border: 1px solid var(--border-strong); border-radius: 14px;
    background: var(--card-bg); color: var(--text-secondary);
    font-size: 11px; font-weight: 600; cursor: pointer;
    transition: all var(--transition); font-family: inherit;
}
.lang-switch:hover { color: var(--accent); border-color: var(--accent); }
.lang-switch-icon { font-size: 13px; }
.lang-switch-wrap { position: relative; }
.lang-switch .lang-caret { font-size: 9px; transition: transform 0.25s cubic-bezier(0.22,0.61,0.36,1); }
.lang-switch-wrap.open .lang-caret { transform: rotate(180deg); }
.lang-menu {
    position: absolute; bottom: calc(100% + 10px); left: 0;
    min-width: 128px; padding: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; gap: 2px;
    opacity: 0; visibility: hidden;
    transform: translateY(12px) scale(0.94);
    transform-origin: bottom left;
    transition: opacity 0.22s cubic-bezier(0.22,0.61,0.36,1), transform 0.22s cubic-bezier(0.22,0.61,0.36,1), visibility 0.22s;
    z-index: 300;
}
.lang-menu.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.lang-menu-item {
    display: flex; align-items: center; width: 100%; padding: 9px 12px;
    border: none; border-radius: 8px; background: transparent;
    color: var(--text-secondary); font-size: 13px; font-weight: 500;
    cursor: pointer; text-align: left; font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.lang-menu-item:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.lang-menu-item.active { color: var(--accent); font-weight: 600; }

/* ================= 在线售卖站 · 后台扩展样式 ================= */
html[data-theme="dark"] {
    --bg: #0d0d0f;
    --sidebar-bg: rgba(28,28,30,0.82);
    --card-bg: rgba(38,38,41,0.9);
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #8e8e93;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-light: rgba(10,132,255,0.16);
    --danger: #FF453A;
    --danger-hover: #FF6961;
    --success: #30D158;
    --warning: #FF9F0A;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.36);
    --shadow: 0 2px 16px rgba(0,0,0,0.46);
}
html[data-theme="dark"] .btn-ghost { background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .btn-ghost:hover { background: rgba(255,255,255,0.13); }
html[data-theme="dark"] .lang-menu-item:hover { background: rgba(255,255,255,0.08); }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { background: rgba(255,255,255,0.05); color: var(--text); }
html[data-theme="dark"] thead th { background: rgba(255,255,255,0.03); }

/* 数据表通用 */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
    text-align: left; padding: 10px 12px; font-size: 11.5px; font-weight: 600;
    color: var(--text-tertiary); letter-spacing: 0.3px; text-transform: uppercase;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(0,0,0,0.018); }
html[data-theme="dark"] .data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.data-table .cell-main { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.data-table .cell-thumb {
    width: 44px; height: 32px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
    background: rgba(0,0,0,0.05); border: 1px solid var(--border);
}
.data-table .cell-title { font-weight: 600; font-size: 13px; line-height: 1.4; }
.data-table .cell-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.table-wrap { overflow-x: auto; }
.table-empty { padding: 36px 12px; text-align: center; font-size: 13px; color: var(--text-tertiary); }
.num-cell { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn {
    height: 26px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border-strong);
    background: transparent; color: var(--text-secondary); font-size: 11.5px; font-weight: 500;
    font-family: inherit; cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }
.mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 工具条 */
.page-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.page-toolbar .grow { flex: 1; }
.toolbar-input {
    height: 34px; padding: 0 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: var(--card-bg);
    color: var(--text); font-size: 13px; font-family: inherit; min-width: 180px;
}
.toolbar-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.toolbar-select {
    height: 34px; padding: 0 10px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: var(--card-bg);
    color: var(--text); font-size: 13px; font-family: inherit; cursor: pointer;
}

/* 商品编辑表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.field .req { color: var(--danger); margin-left: 2px; }
.field input[type="text"], .field input[type="number"], .field input[type="password"],
.field input[type="email"], .field select, .field textarea {
    width: 100%; padding: 9px 12px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: var(--bg);
    color: var(--text); font-size: 13px; font-family: inherit; transition: all var(--transition);
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); background: var(--card-bg);
}
.field .hint { font-size: 11px; color: var(--text-tertiary); line-height: 1.5; }
.field-row { display: flex; gap: 10px; align-items: center; }
.price-input { display: flex; align-items: center; gap: 0; }
.price-input .cur-tag {
    height: 38px; padding: 0 12px; display: inline-flex; align-items: center;
    border: 1px solid var(--border-strong); border-right: none; border-radius: 8px 0 0 8px;
    background: rgba(0,0,0,0.04); color: var(--text-secondary); font-size: 12px; font-weight: 600;
}
html[data-theme="dark"] .price-input .cur-tag { background: rgba(255,255,255,0.06); }
.price-input input { border-radius: 0 8px 8px 0 !important; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 12.5px; color: var(--text-secondary); }
.switch input { display: none; }
.switch .track {
    width: 40px; height: 23px; border-radius: 12px; background: rgba(120,120,128,0.28);
    position: relative; transition: all 0.24s cubic-bezier(0.22,0.61,0.36,1); flex-shrink: 0;
}
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: all 0.24s cubic-bezier(0.22,0.61,0.36,1);
}
.switch input:checked + .track { background: #34C759; }
.switch input:checked + .track::after { transform: translateX(17px); }

/* 封面上传 */
.cover-drop {
    display: flex; align-items: center; gap: 14px; padding: 12px;
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
    background: rgba(0,0,0,0.015); cursor: pointer; transition: all var(--transition);
}
html[data-theme="dark"] .cover-drop { background: rgba(255,255,255,0.03); }
.cover-drop:hover, .cover-drop.dragover { border-color: var(--accent); background: var(--accent-light); }
.cover-preview {
    width: 96px; height: 66px; border-radius: 8px; flex-shrink: 0; object-fit: cover;
    background: rgba(0,0,0,0.06); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); font-size: 11px;
}
.cover-drop .cover-text { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; }
.cover-drop .cover-text b { color: var(--accent); font-weight: 600; }

/* 商品文件块 */
.file-slot {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: rgba(0,0,0,0.015);
}
html[data-theme="dark"] .file-slot { background: rgba(255,255,255,0.03); }
.file-slot .fs-icon { width: 32px; height: 32px; flex-shrink: 0; }
.file-slot .fs-info { flex: 1; min-width: 0; }
.file-slot .fs-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-slot .fs-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* 分段 tab（设置页） */
.seg-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(120,120,128,0.14); margin-bottom: 18px; flex-wrap: wrap; }
.seg-tabs button {
    height: 30px; padding: 0 15px; border: none; border-radius: 8px; background: transparent;
    color: var(--text-secondary); font-size: 12.5px; font-weight: 500; font-family: inherit;
    cursor: pointer; transition: all var(--transition);
}
.seg-tabs button.active { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* 统计卡补充 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-box {
    padding: 16px 18px; border-radius: var(--radius); background: var(--card-bg);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.stat-box .sb-k { font-size: 11.5px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.stat-box .sb-v { margin-top: 8px; font-size: 24px; font-weight: 700; letter-spacing: -0.8px; color: var(--text); }
.stat-box .sb-v small { font-size: 12px; font-weight: 600; color: var(--text-tertiary); margin-left: 3px; }
.stat-box .sb-sub { margin-top: 4px; font-size: 11px; color: var(--text-tertiary); }

/* 登录页 */
/* 布局修正：body 上的 display:flex 是给后台主界面（.sidebar + .main）用的，
   登录页会因此把 .login-screen 当作 flex item 收缩到内容宽度并贴靠左侧，
   表现为登录卡片不居中、右侧出现大片空白。这里在登录页恢复块级布局。 */
.login-body { display: block; }

.login-screen {
    width: 100%;
    min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
    padding: 24px; background:
        radial-gradient(900px 460px at 50% -140px, rgba(0,122,255,0.16), transparent 70%), var(--bg);
}
.login-card {
    width: 100%; max-width: 372px; padding: 30px 28px 26px;
    background: var(--card-bg); border: 1px solid var(--border-strong);
    border-radius: 18px; box-shadow: 0 22px 60px rgba(0,0,0,0.14);
    backdrop-filter: saturate(180%) blur(22px);
}
.login-card .lc-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-card .lc-logo img { width: 32px; height: 32px; border-radius: 8px; }
.login-card .lc-logo b { font-size: 15px; font-weight: 700; }
.login-card h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 6px; }
.login-card .lc-sub { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; height: 40px; margin-top: 4px; }
.login-card .back-home { display: block; text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-tertiary); }

/* 图表 */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 132px; padding: 8px 4px 0; }
.bar-chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-chart .bar {
    width: 100%; max-width: 34px; border-radius: 5px 5px 2px 2px;
    background: linear-gradient(180deg, var(--accent), rgba(0,122,255,0.42));
    min-height: 3px; transition: height 0.4s cubic-bezier(0.22,0.61,0.36,1);
}
.bar-chart .bar-label { font-size: 10px; color: var(--text-tertiary); white-space: nowrap; }
.chart-empty { height: 132px; display: flex; align-items: center; justify-content: center; font-size: 12.5px; color: var(--text-tertiary); }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .data-table .cell-main { min-width: 150px; }
}

/* ============================================================
   后台交互增强层（动画变量 / 骨架屏 / 统一 toast / 列表 / 表单校验）
   仅动 transform 与 opacity，不触发布局动画
   ============================================================ */
:root {
    --dur-fast: 160ms;
    --dur-base: 240ms;
    --dur-slow: 360ms;
    --ease: cubic-bezier(.32, .72, 0, 1);
}

/* ---------- 通用入场 ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translate3d(0, 10px, 0); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

#main, .page-toolbar, .stat-grid, .panel { animation: fadeUp var(--dur-slow) var(--ease) both; }

/* ---------- 统一 toast 堆叠 ---------- */
.toast-stack {
    position: fixed; top: 18px; right: 18px; z-index: 1200;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none; max-width: min(380px, calc(100vw - 32px));
}
.toast-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 14px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--border-strong);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.12);
    color: var(--text); font-size: 13px; line-height: 1.45; font-weight: 500;
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    pointer-events: auto;
    will-change: transform, opacity;
    animation: toastSlide var(--dur-base) var(--ease) both;
}
@keyframes toastSlide { from { opacity: 0; transform: translate3d(24px, -6px, 0) scale(.96); } to { opacity: 1; transform: none; } }
.toast-item.out { animation: toastOut var(--dur-fast) var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translate3d(18px, -4px, 0) scale(.96); } }
.toast-item .ti-ic { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.toast-item .ti-ic svg { width: 18px; height: 18px; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.toast-item.success .ti-ic { color: var(--success); stroke: var(--success); }
.toast-item.error .ti-ic { color: var(--danger); stroke: var(--danger); }
.toast-item.warn .ti-ic { color: #FF9F0A; stroke: #FF9F0A; }
.toast-item.info .ti-ic { color: var(--accent); stroke: var(--accent); }
.toast-item.success { border-left: 3px solid var(--success); }
.toast-item.error { border-left: 3px solid var(--danger); }
.toast-item.warn { border-left: 3px solid #FF9F0A; }
.toast-item.info { border-left: 3px solid var(--accent); }
.toast-item .ti-msg { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.toast-item .ti-close {
    flex: 0 0 auto; width: 20px; height: 20px; border: none; border-radius: 50%;
    background: rgba(0, 0, 0, 0.06); color: var(--text-secondary);
    font-size: 12px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.toast-item .ti-close:hover { background: rgba(0, 0, 0, 0.12); color: var(--text); }

/* 兼容登录页遗留 toast 节点 */
.toast { display: none !important; }

/* ---------- 工具栏 ---------- */
.toolbar-select {
    height: 34px; padding: 0 30px 0 12px; border-radius: 10px;
    border: 1px solid var(--border-strong); background: var(--card-bg); color: var(--text);
    font-size: 13px; -webkit-appearance: none; appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.toolbar-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ---------- 可排序表头 ---------- */
.data-table th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; transition: color var(--dur-fast) var(--ease); }
.data-table th.th-sort:hover { color: var(--text); }
.data-table th .sort-ind { display: inline-block; width: 0; height: 0; margin-left: 5px; vertical-align: middle; opacity: 0; transition: opacity var(--dur-fast) var(--ease), transform var(--dur-base) var(--ease); }
.data-table th.sorted .sort-ind { opacity: 1; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--accent); }
.data-table th.sorted.asc .sort-ind { transform: rotate(180deg); }

/* ---------- 表格行 ---------- */
.row-enter { animation: fadeUp var(--dur-base) var(--ease) both; animation-delay: var(--d, 0ms); }
.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.cell-flex { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-thumb {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; overflow: hidden;
    background: rgba(0, 0, 0, 0.05); display: flex; align-items: center; justify-content: center;
}
.cell-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cell-main { font-weight: 600; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.cell-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.status-pill {
    display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
    border-radius: 11px; font-size: 11px; font-weight: 600; white-space: nowrap;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.status-pill.on { background: rgba(52, 199, 89, 0.14); color: #248A3D; }
.status-pill.off { background: rgba(142, 142, 147, 0.16); color: #6C6C70; }
.row-actions { display: flex; gap: 4px; flex-wrap: nowrap; }
.row-actions .btn { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 8px; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(255, 59, 48, 0.1); color: var(--danger-hover); }

/* ---------- 骨架屏 ---------- */
.skel-row td { padding-top: 14px; padding-bottom: 14px; }
.skel-line {
    height: 10px; border-radius: 5px; margin: 3px 0;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.06) 25%, rgba(0, 0, 0, 0.11) 37%, rgba(0, 0, 0, 0.06) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s linear infinite;
}
.skel-line.w30 { width: 30%; }
.skel-line.w60 { width: 60%; }
.skel-line.w70 { width: 70%; }
.skel-line.w80 { width: 80%; }
.skel-card { height: 96px; border-radius: var(--radius-lg); background: rgba(255, 255, 255, 0.6); border: 1px solid var(--border); }
.skel-block {
    border-radius: var(--radius-lg); min-height: 96px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.1) 37%, rgba(0, 0, 0, 0.05) 63%);
    background-size: 400% 100%; animation: shimmer 1.4s linear infinite;
}
.skel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.skel-grid .skel-block { height: 92px; }

/* ---------- 加载态按钮 ---------- */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px;
    margin: -7px 0 0 -7px; border-radius: 50%;
    border: 2px solid currentColor; border-top-color: transparent;
    color: var(--text); opacity: .65; animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { color: #fff; opacity: 1; }
.btn:active { transform: scale(.97); }
.btn { transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }

/* ---------- 表单校验 ---------- */
.field input.invalid, .field textarea.invalid, .field select.invalid,
input.invalid, textarea.invalid, select.invalid {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
    animation: shake .28s var(--ease);
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.form-error-banner {
    display: none; margin-bottom: 14px; padding: 11px 13px; border-radius: 12px;
    background: rgba(255, 59, 48, 0.08); border: 1px solid rgba(255, 59, 48, 0.22);
    color: var(--danger-hover); font-size: 12.5px; line-height: 1.55;
}
.form-error-banner.show { display: block; animation: fadeUp var(--dur-base) var(--ease) both; }
.form-error-banner .feb-title { font-weight: 700; margin-bottom: 4px; }
.form-error-banner ul { margin: 0; padding-left: 16px; }
.form-error-banner li { list-style: disc; }

/* ---------- 上传进度 ---------- */
.up-progress { display: none; margin-top: 12px; }
.up-progress.show { display: block; animation: fadeIn var(--dur-base) var(--ease) both; }
.up-progress .up-bar { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.up-progress .up-bar span {
    display: block; height: 100%; width: 0; border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), #5AC8FA);
    transition: width var(--dur-base) var(--ease);
}
.up-progress .up-text { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.up-progress.done .up-bar span { background: var(--success); }
.up-progress.done .up-text { color: #248A3D; }
.up-progress.fail .up-text { color: var(--danger); }
.up-progress.parsing .up-bar span { background: linear-gradient(90deg, var(--accent), #5AC8FA); opacity: .75; }
.up-progress.parsing .up-text { color: var(--accent); }
.up-progress .up-text { transition: color var(--dur-base) var(--ease); }

/* ---------- 弹窗入场（后台） ---------- */
.modal-overlay.active { animation: fadeIn var(--dur-base) var(--ease) both; }
.modal-overlay.active > .modal { animation: modalIn var(--dur-base) var(--ease) both; }
@keyframes modalIn { from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes modalOut { to { opacity: 0; transform: translate3d(0, 8px, 0) scale(.97); } }

/* ---------- 移动端 ---------- */
@media (max-width: 900px) {
    .toast-stack { left: 12px; right: 12px; max-width: none; top: 12px; }
    .cell-main { max-width: 180px; }
    .row-actions { flex-wrap: wrap; }
}

/* ---------- 无障碍降级 ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-delay: 0ms !important;
        transition-duration: .001ms !important;
    }
    .row-enter, #main, .page-toolbar, .stat-grid, .panel { animation: none !important; opacity: 1 !important; transform: none !important; }
}
