/* ============ 安筑商城 - 后台样式 ============ */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --sidebar-bg: #111827;
    --sidebar-active: #4f46e5;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --green: #10b981;
    --red: #ef4444;
    --orange: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }

.mono { font-family: "SFMono-Regular", Consolas, monospace; }

/* ============ 登录页 ============ */
.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
    display: flex; align-items: center; justify-content: center;
}

.login-wrap { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: #fff; border-radius: 18px;
    padding: 40px 36px;
    box-shadow: 0 24px 60px rgba(30, 27, 75, 0.45);
}

.login-brand { text-align: center; margin-bottom: 28px; }

.login-logo {
    width: 64px; height: 64px; margin: 0 auto 12px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-radius: 16px; color: #fff;
    font-size: 30px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.login-brand h1 { font-size: 20px; color: var(--text); }
.login-brand p { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.login-form .form-item { margin-bottom: 18px; }

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

.login-form input {
    width: 100%; height: 46px;
    border: 1.5px solid var(--border); border-radius: 10px;
    padding: 0 14px; font-size: 14px; outline: none;
    transition: all 0.2s;
}

.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }

.login-btn {
    width: 100%; height: 46px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 700; cursor: pointer;
    margin-top: 6px; transition: all 0.25s;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.login-btn:hover { transform: translateY(-2px); }

.login-tip { text-align: center; font-size: 12px; color: var(--text-light); margin-top: 18px; }

/* ============ 后台布局 ============ */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px; background: var(--sidebar-bg);
    position: fixed; top: 0; bottom: 0; left: 0;
    overflow-y: auto; z-index: 50;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand .logo {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-radius: 10px; color: #fff;
    font-size: 17px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}

.sidebar-brand .name { color: #fff; font-size: 16px; font-weight: 700; }

.side-nav { padding: 12px 0 24px; }

.nav-group { margin-bottom: 8px; }

.nav-group-title {
    padding: 10px 20px 6px;
    font-size: 11px; color: #6b7280;
    text-transform: uppercase; letter-spacing: 1px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 20px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none; font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.nav-item.active {
    color: #fff; background: rgba(79, 70, 229, 0.25);
    border-left-color: var(--sidebar-active);
}

.main-area { flex: 1; margin-left: 230px; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    background: var(--card);
    padding: 0 28px;
    height: 64px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 40;
}

.page-title { font-size: 18px; color: var(--text); }

.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }

.avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
}

.logout-link { color: var(--text-light); text-decoration: none; font-size: 13px; }
.logout-link:hover { color: var(--red); }

.content-area { padding: 24px 28px 40px; flex: 1; }

/* ============ 统计卡片 ============ */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 24px; }

.stat-card {
    background: var(--card); border-radius: 14px;
    padding: 20px 22px;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid var(--border);
    transition: all 0.25s;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08); }

.stat-icon {
    width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}

.stat-icon.blue { background: #eef2ff; }
.stat-icon.green { background: #ecfdf5; }
.stat-icon.purple { background: #f5f3ff; }
.stat-icon.orange { background: #fffbeb; }

.stat-info { display: flex; flex-direction: column; }

.stat-label { font-size: 12.5px; color: var(--text-light); }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); }
.stat-sub { font-size: 11.5px; color: var(--text-light); margin-top: 2px; }

/* ============ 面板 ============ */
.panel {
    background: var(--card); border-radius: 14px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-head {
    padding: 16px 22px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.panel-head h3 { font-size: 15px; }

.panel-link { color: var(--primary); text-decoration: none; font-size: 13px; }
.panel-link:hover { text-decoration: underline; }

.panel-body { padding: 18px 22px; }

.panel-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
.panel-half { margin-bottom: 0; }

/* ============ 工具栏 ============ */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 18px;
}

.toolbar-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.toolbar-form select, .toolbar-form input {
    height: 38px; border: 1.5px solid var(--border); border-radius: 8px;
    padding: 0 12px; font-size: 13px; outline: none; background: #fff;
}

.toolbar-form input { width: 220px; }

.toolbar-form select:focus, .toolbar-form input:focus { border-color: var(--primary); }

.toolbar-actions { display: flex; gap: 10px; }

/* ============ 按钮 ============ */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: none; border-radius: 8px;
    padding: 10px 24px; font-size: 13.5px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: all 0.2s;
}

.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }

.btn-outline {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary); border-radius: 8px;
    padding: 9px 22px; font-size: 13.5px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: all 0.2s;
}

.btn-outline:hover { background: #eef2ff; }

.btn-sm { padding: 7px 16px; font-size: 13px; }

.btn-mini {
    display: inline-block; padding: 4px 12px;
    border-radius: 6px; font-size: 12px;
    background: #eef2ff; color: var(--primary);
    text-decoration: none; margin-right: 4px; transition: all 0.2s;
}

.btn-mini:hover { background: var(--primary); color: #fff; }

.btn-mini.btn-red { background: #fef2f2; color: var(--red); }
.btn-mini.btn-red:hover { background: var(--red); color: #fff; }

.btn-mini.btn-orange { background: #fffbeb; color: #b45309; }
.btn-mini.btn-orange:hover { background: var(--orange); color: #fff; }

/* ============ 表格 ============ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.data-table th {
    text-align: left; padding: 12px 10px;
    color: var(--text-light); font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: #f8fafc;
}

.data-table td { padding: 12px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }

.data-table tbody tr:hover { background: #f8fafc; }

.data-table tbody tr:last-child td { border-bottom: none; }

.goods-name-cell { font-weight: 600; color: var(--text); }

.amount-td { color: var(--red); font-weight: 700; }

.original-price { color: #94a3b8; text-decoration: line-through; font-size: 12px; font-weight: 400; }

.card-cell { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.empty-td { text-align: center; color: var(--text-light); padding: 40px 0 !important; }

.action-td { white-space: nowrap; }

/* ============ 徽章 ============ */
.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 50px; font-size: 11.5px; font-weight: 600;
}

.badge-green { background: #ecfdf5; color: #059669; }
.badge-orange { background: #fffbeb; color: #b45309; }
.badge-red { background: #fef2f2; color: var(--red); }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ============ 表单 ============ */
.panel-form { max-width: 860px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }

.form-item { margin-bottom: 18px; }
.form-item.full { grid-column: 1 / -1; }

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

.form-item input[type="text"], .form-item input[type="password"], .form-item input[type="number"], .form-item select, .form-item textarea {
    width: 100%; border: 1.5px solid var(--border); border-radius: 8px;
    padding: 10px 12px; font-size: 13.5px; outline: none;
    transition: all 0.2s; background: #fff; font-family: inherit;
}

.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-item textarea { resize: vertical; line-height: 1.6; }

.req { color: var(--red); }

.form-hint { display: block; font-size: 12px; color: var(--text-light); margin-top: 5px; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1; border-radius: 24px; transition: 0.3s;
}
.slider:before {
    content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(22px); }

/* ============ 趋势图 ============ */
.trend-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; height: 190px; padding: 10px 4px 0; }

.trend-col { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 6px; }

.trend-bar {
    width: 70%; min-width: 28px; max-width: 52px;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    border-radius: 8px 8px 2px 2px;
    transition: height 0.5s;
    position: relative;
}

.trend-col:nth-child(odd) .trend-bar { background: linear-gradient(180deg, #a78bfa, #7c3aed); }

.trend-val { font-size: 11px; color: var(--text); font-weight: 600; }
.trend-date { font-size: 11px; color: var(--text-light); }

/* ============ 详情页 ============ */
.detail-box { background: #f8fafc; border-radius: 10px; padding: 6px 20px; }

.detail-row { display: flex; justify-content: space-between; padding: 13px 0; border-bottom: 1px dashed #e2e8f0; font-size: 13.5px; }

.detail-row:last-child { border-bottom: none; }

.detail-row span { color: var(--text-light); }

.detail-row b { color: var(--text); font-weight: 600; }

.detail-sub { margin: 22px 0 10px; font-size: 14px; }

.card-preview textarea {
    width: 100%; border: 1.5px solid #bbf7d0; border-radius: 10px;
    padding: 14px; font-size: 13px; background: #f0fdf4; color: #14532d;
    font-family: "SFMono-Regular", Consolas, monospace;
    resize: vertical; outline: none;
}

/* ============ 弹窗 ============ */
.modal-mask {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}

.modal {
    background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
    animation: modalIn 0.25s;
}

@keyframes modalIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

.modal-head h3 { font-size: 15px; }

.modal-close { background: none; border: none; font-size: 22px; color: var(--text-light); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--red); }

.modal-body { padding: 20px 22px; }

.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ 提示框 ============ */
.notice-box {
    margin-top: 20px; padding: 14px 18px;
    background: #eef2ff; border: 1px solid #e0e7ff; border-radius: 10px;
    font-size: 13px; color: #4338ca; line-height: 1.7;
}

/* ============ 分页（后台） ============ */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }

.pagination a, .pagination span {
    min-width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 12.5px; color: var(--text-light); text-decoration: none;
    padding: 0 8px; background: #fff;
}

.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
    .panel-row { grid-template-columns: 1fr; }
    .sidebar { width: 190px; }
    .main-area { margin-left: 190px; }
    .form-grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
}
