/* ============================================================
 * 基础样式 —— 变量、按钮、卡片、表格、表单、徽章
 * ============================================================ */

:root {
    --blue: #007aff;
    --blue-hover: #0066d6;
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --purple: #af52de;
    --wechat: #07c160;
    --alipay: #1677ff;
    --gray: #6e6e73;

    --bg: #f5f5f7;
    --card: #fff;
    --text: #1d1d1f;
    --text2: #6e6e73;
    --line: #e5e5ea;
    --line2: #f0f0f2;

    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; outline: none; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: .15s;
    background: #e9e9eb;
    color: var(--text);
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary:hover { background: #ddd; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #d92d24; }
.btn-warning { background: var(--orange); color: #fff; }
.btn-ghost { background: transparent; color: var(--text2); padding: 8px 14px; font-size: 14px; }
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============ 卡片 ============ */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }

/* ============ 输入 ============ */
.input, select.input, textarea.input {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: #fff;
    transition: .15s;
    box-sizing: border-box;
    color: var(--text);
}
.input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(0,122,255,.12);
}
.input-sm { max-width: 120px; }

/* ============ 表格 ============ */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}
.table th {
    background: #f5f5f7;
    padding: 11px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td {
    padding: 13px 14px;
    font-size: 14px;
    border-bottom: 1px solid var(--line2);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafb; }
.table a { color: var(--blue); }
.table a:hover { text-decoration: underline; }

/* ============ 徽章 ============ */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: #f5f5f7;
    color: var(--text2);
}
.badge-gold { background: rgba(255,204,0,.15); color: #a67c00; }
.badge-diamond { background: rgba(175,82,222,.15); color: #8e3eb8; }
.badge-trial { background: rgba(0,122,255,.12); color: #0055b3; }
.badge-normal { background: #f5f5f7; color: var(--text2); }
.badge-green { background: rgba(52,199,89,.12); color: #1e8e3e; }
.badge-red { background: rgba(255,59,48,.12); color: #c92a22; }
.badge-super { background: linear-gradient(135deg,#ffcc00,#ff9500); color: #fff; }

/* 支付方式徽章 */
.badge-cash { background: rgba(255,149,0,.15); color: #c26a00; }
.badge-wechat { background: rgba(7,193,96,.15); color: #06a04d; }
.badge-alipay { background: rgba(22,119,255,.15); color: #0d5fd0; }
.badge-card { background: rgba(175,82,222,.15); color: #8e3eb8; }
.badge-credit { background: rgba(142,142,147,.15); color: #636366; }
.badge-preorder { background: rgba(0,122,255,.12); color: #0055b3; }

/* ============ 提示条 ============ */
.notice {
    padding: 12px 18px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
.notice-success { background: rgba(52,199,89,.12); color: #1e8e3e; border-left: 4px solid var(--green); }
.notice-error { background: rgba(255,59,48,.12); color: #c92a22; border-left: 4px solid var(--red); }
.notice-info { background: rgba(0,122,255,.1); color: #0055b3; border-left: 4px solid var(--blue); }
.notice-warning { background: rgba(255,149,0,.12); color: #c26a00; border-left: 4px solid var(--orange); }

/* ============ 表单表格 ============ */
.form-table { width: 100%; }
.form-table th {
    text-align: left;
    padding: 12px 16px 12px 0;
    font-size: 14px;
    font-weight: 500;
    width: 160px;
    vertical-align: top;
}
.form-table td { padding: 8px 0; }

/* ============ 网格 ============ */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============ 统计卡 ============ */
.stat {
    padding: 20px;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.stat-label {
    font-size: 12px;
    color: var(--text2);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
    letter-spacing: -.02em;
}
.stat-sub {
    font-size: 11.5px;
    color: var(--text2);
    margin-top: 6px;
    line-height: 1.5;
}

/* ============ 开关 ============ */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #e9e9eb;
    border-radius: 14px;
    transition: .2s;
}
.slider:before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
    box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ============ 辅助 ============ */
.text-muted { color: var(--text2); }
.text-small { font-size: 13px; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.key-box {
    display: inline-block;
    padding: 7px 12px;
    background: #f5f5f7;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    font-weight: 600;
}
.code-box {
    display: inline-block;
    padding: 12px 20px;
    background: linear-gradient(135deg, #007aff, #5856d6);
    color: #fff;
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
}
/* ============ 商品图片 ============ */
.image-upload-wrap {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.image-preview {
    width: 120px;
    height: 120px;
    border: 2px dashed var(--line);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafb;
    flex-shrink: 0;
}
.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.image-upload-actions {
    flex: 1;
    min-width: 200px;
    padding-top: 8px;
}
.product-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    background: #f5f5f7;
    display: block;
}