/* 卡密系统全站样式：用户端 + 后台 + 登录页 */

:root {
    --bg: #f4f5fa;
    --card: #ffffff;
    --ink: #16181d;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --accent-soft: #eef2ff;
    --ok: #059669;
    --ok-soft: #ecfdf5;
    --bad: #dc2626;
    --bad-soft: #fef2f2;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: .92em; }
.muted { color: var(--muted); }
.right { text-align: right; }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }

/* 数字等宽对齐（余额/统计/表格） */
.table td, .balance-num, .stat-num, .trend-num { font-variant-numeric: tabular-nums; }

/* 键盘焦点可见性 */
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* 入场与提示动画（尊重系统减动效偏好） */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.card, .goods-card, .stat-card { animation: fadeUp .3s ease backwards; }
.flash { animation: fadeUp .25s ease; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== 顶栏（用户端） ===== */
.site-header {
    background: #171923;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.bar { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .5px; display: flex; align-items: center; gap: 9px; }
.brand img { width: 24px; height: 24px; border-radius: 7px; display: block; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
    color: #cbd5e1;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
}
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.bar-right { display: flex; align-items: center; gap: 10px; }
.bar-right .chip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.announce {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 13.5px;
    padding: 8px 0;
}

.main { padding: 28px 20px 48px; }

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

/* ===== 首页商品 ===== */
.hero {
    text-align: center;
    padding: 44px 24px 36px;
    margin: 24px 0 22px;
    border-radius: 20px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.hero::before, .hero::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .30;
    pointer-events: none;
}
.hero::before {
    background: #818cf8;
    top: -140px;
    left: -60px;
    animation: blobDrift 16s ease-in-out infinite alternate;
}
.hero::after {
    background: #c4b5fd;
    bottom: -160px;
    right: -50px;
    animation: blobDrift 20s ease-in-out infinite alternate-reverse;
}
@keyframes blobDrift {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(46px, 24px) scale(1.18); }
}
.hero > * { position: relative; z-index: 1; }
.hero h1 {
    margin: 0 0 10px;
    font-size: 32px;
    letter-spacing: 1px;
    background: linear-gradient(120deg, #4338ca, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p { margin: 0 0 6px; color: var(--muted); }
.hero .buy-note { max-width: 640px; margin: 14px auto 0; text-align: left; white-space: pre-line; }

.goods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}
.goods-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--ink);
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    display: flex;
    flex-direction: column;
}
.goods-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(79, 70, 229, .18);
    border-color: #c7d2fe;
}
.goods-card::after {
    content: '查看详情 →';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 9px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(100%);
    transition: transform .2s ease;
}
.goods-card:hover::after { transform: translateY(0); }
.goods-card { position: relative; }
.goods-media { position: relative; overflow: hidden; }
.goods-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(17, 16, 39, .62);
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}
.goods-photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; transition: transform .25s ease; }
.goods-card:hover .goods-photo { transform: scale(1.04); }
.goods-photo.placeholder,
.goods-detail-photo.placeholder,
.thumb.placeholder,
.auth-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
}
.goods-photo.placeholder { font-size: 44px; }
.goods-body { padding: 14px 16px 16px; }
.goods-title { font-weight: 600; margin-bottom: 6px; }
.goods-desc {
    color: var(--muted);
    font-size: 13px;
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty { color: var(--muted); text-align: center; padding: 32px 0; }

/* ===== 通用卡片 / 表单 ===== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.card h3 {
    margin: 0 0 14px;
    font-size: 16.5px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.card h3::before {
    content: '';
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    flex-shrink: 0;
}
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.note {
    background: var(--accent-soft);
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 14px;
    font-size: 14px;
}
.steps { padding-left: 20px; }
.steps li { margin-bottom: 8px; }

label { display: block; font-size: 13.5px; font-weight: 600; margin: 12px 0 6px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    border-color: var(--accent);
}
input[type="file"] { padding: 8px 0; display: block; width: 100%; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #4f46e5, #6d28d9);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .3);
    transition: filter .15s ease, transform .1s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; margin-top: 16px; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--accent); border-color: #c7d2fe; box-shadow: none; }
.btn.ghost:hover { background: var(--accent-soft); filter: none; }
.btn.danger { background: transparent; color: var(--bad); border-color: #fecaca; box-shadow: none; }
.btn.danger:hover { background: var(--bad-soft); filter: none; }

.site-header .btn.ghost { color: #cbd5e1; border-color: rgba(255, 255, 255, .25); }
.site-header .btn.ghost:hover { background: rgba(255, 255, 255, .08); }

/* ===== 提示条 ===== */
.flash {
    border-radius: 10px;
    padding: 11px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.flash.bad { background: var(--bad-soft); color: var(--bad); border-color: #fecaca; }

/* ===== 面板 ===== */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
    align-items: start;
}
.balance-hero {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-radius: 12px;
    text-align: center;
    padding: 20px 0 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}
.balance-hero::before {
    content: '';
    position: absolute;
    top: -70%;
    left: -15%;
    width: 75%;
    height: 170%;
    background: radial-gradient(closest-side, rgba(255, 255, 255, .28), transparent);
    transform: rotate(18deg);
    pointer-events: none;
}
.balance-hero > * { position: relative; }
.balance-num { font-size: 40px; font-weight: 800; line-height: 1.1; }
.balance-label { font-size: 13px; opacity: .85; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; word-break: break-all; }

.chip {
    display: inline-block;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(120, 130, 150, .25);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12.5px;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: #c7d2fe; }

/* ===== 表格 ===== */
.table-scroll { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 10px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid #f1f2f6; vertical-align: middle; white-space: nowrap; }
.table td.wrap { white-space: normal; min-width: 220px; }
.table tbody tr:nth-child(even) { background: #fafbfd; }
.table tbody tr:hover { background: #f4f6ff; }
.table .clip { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.table .actions { flex-wrap: nowrap; }
.actions form { margin: 0; }
.inline-edit { display: inline-flex; gap: 4px; align-items: center; }
.inline-edit input { width: 110px; padding: 5px 8px; font-size: 12.5px; border-radius: 8px; }
.inline-edit select { width: 130px; padding: 5px 6px; font-size: 12.5px; border-radius: 8px; }

.check-line { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check-line input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.tab-bar.center { justify-content: center; margin-bottom: 22px; }

/* ===== 状态徽章 ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .75;
    flex-shrink: 0;
}
.badge.pending { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge.running { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge.password_change { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.badge.done { background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0; }
.badge.refunded { background: #f3f4f6; color: #6b7280; border: 1px solid var(--line); }

/* ===== 分页 ===== */
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 13.5px;
}

/* ===== 登录页（bare） ===== */
body.bare {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1000px 600px at 20% 0%, #312e81 0%, #1e1b4b 45%, #111027 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
body.bare::before, body.bare::after {
    content: '';
    position: fixed;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .32;
    pointer-events: none;
}
body.bare::before {
    background: #6366f1;
    top: -140px;
    right: -80px;
    animation: blobDrift 18s ease-in-out infinite alternate;
}
body.bare::after {
    background: #a78bfa;
    bottom: -160px;
    left: -100px;
    animation: blobDrift 22s ease-in-out infinite alternate-reverse;
}
.bare-wrap { position: relative; z-index: 1; }
.bare-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    padding: 32px 30px 26px;
}
.auth-head { text-align: center; margin-bottom: 8px; }
.auth-badge {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    font-size: 26px;
    margin: 0 auto 12px;
}
.auth-head h2 { margin: 0 0 4px; font-size: 20px; }
.auth-head p { margin: 0; color: var(--muted); font-size: 13.5px; }
.back-link { display: block; text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.back-link:hover { color: var(--accent); }

/* ===== 后台布局 ===== */
body.admin { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #171923;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.side-brand {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    padding: 22px 20px 18px;
    line-height: 1.3;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 9px;
}
.side-brand img { width: 26px; height: 26px; border-radius: 7px; grid-row: span 2; }
.side-brand span { display: block; font-size: 12px; font-weight: 400; color: #94a3b8; }
.side-nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; flex: 1; }
.side-nav a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.side-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.side-foot .chip { color: #e2e8f0; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.side-foot form { margin: 0; }
.side-foot .btn.ghost { color: #cbd5e1; border-color: rgba(255, 255, 255, .2); }

.admin-main { flex: 1; padding: 26px 30px 48px; min-width: 0; }
.page-title { margin: 0 0 18px; font-size: 21px; }

/* ===== 仪表盘统计卡 ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    color: var(--ink);
}
.stat-card:hover { border-color: #c7d2fe; }
.stat-card.highlight { background: linear-gradient(135deg, #4f46e5, #7c3aed); border: none; color: #fff; }
.stat-card.highlight .stat-label { color: rgba(255, 255, 255, .8); }
.stat-num { font-size: 28px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }

.more-link { margin-left: auto; font-size: 13px; font-weight: 400; }

/* ===== 仪表盘趋势图 ===== */
.trend {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 140px;
    padding-top: 8px;
}
.trend-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
}
.trend-num { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.trend-bar {
    width: 70%;
    max-width: 48px;
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 6px 6px 0 0;
    transition: height .2s ease;
}
.trend-label { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* ===== 商品详情页 ===== */
.goods-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 8px;
}
.goods-detail-photo {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: block;
}
.goods-detail-photo.placeholder { font-size: 72px; }
.goods-detail-title { margin: 0 0 10px; font-size: 24px; }
.goods-detail-meta { display: flex; gap: 8px; margin-bottom: 14px; }
.goods-detail-desc {
    color: var(--ink);
    white-space: pre-line;
    line-height: 1.8;
    margin-bottom: 18px;
}
@media (max-width: 760px) {
    .goods-detail { grid-template-columns: 1fr; }
}

.delta-pos { color: var(--ok); font-weight: 700; }
.delta-neg { color: var(--bad); font-weight: 700; }

.token-cell { width: 150px; padding: 4px 8px; font-size: 12px; border-radius: 8px; }

.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; }

/* ===== 搜索栏 ===== */
.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex: 1; }
.search-bar input[type="search"] { max-width: 320px; padding: 8px 12px; }
.toolbar .search-bar { margin-bottom: 0; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.toolbar > .btn:only-child { margin-left: auto; }

/* ===== 标签页 ===== */
.tab-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 600;
}
.tab:hover { border-color: #c7d2fe; color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab .count {
    background: rgba(0, 0, 0, .08);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
}
.tab.active .count { background: rgba(255, 255, 255, .22); }

/* ===== 缩略图 ===== */
.thumb {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    display: block;
}
.thumb.placeholder { font-size: 20px; }
.thumb.large { width: 96px; height: 96px; margin: 6px 0; }

/* ===== 响应式 ===== */
@media (max-width: 760px) {
    .bar { flex-wrap: wrap; padding: 10px 0; row-gap: 4px; }
    .bar-right { margin-left: auto; }
    .bar-right .chip { max-width: 96px; }
    .tabs { order: 3; flex: 0 0 100%; overflow-x: auto; flex-wrap: nowrap; }
    .tabs a { white-space: nowrap; flex-shrink: 0; }
    body.admin { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .side-nav { flex-direction: row; overflow-x: auto; padding-bottom: 10px; }
    .side-nav a { white-space: nowrap; flex-shrink: 0; }
    .admin-main { padding: 18px 16px 40px; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dt { margin-top: 8px; }
    .toolbar { flex-wrap: wrap; }
}
