/* ============================================================
   维昆企服推广返利系统 - 全局样式
   ============================================================ */

:root {
    --primary: #1677ff;
    --primary-hover: #4096ff;
    --success: #52c41a;
    --warning: #fa8c16;
    --danger: #ff4d4f;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border: #e8e8e8;
    --radius: 8px;
    --shadow: 0 1px 4px rgba(0,0,0,0.08);
    --header-height: 56px;
    --sidebar-width: 200px;
    --sidebar-collapsed: 56px;
    --font: -apple-system, PingFang SC, Microsoft YaHei, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ========== 布局 ========== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width);
    background: #001529;
    color: #fff;
    flex-shrink: 0;
    transition: width 0.3s;
    display: flex;
    flex-direction: column;
}
.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-menu {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}
.sidebar-menu .menu-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}
.sidebar-menu .menu-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.sidebar-menu .menu-item.active {
    color: #fff;
    background: var(--primary);
}
.sidebar-menu .menu-item .menu-icon {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-menu .menu-section {
    padding: 8px 16px 4px;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.header {
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}
.header-user {
    color: var(--text-secondary);
}
.content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}
.page-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* ========== 数据卡片 ========== */
.card-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.card-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.card-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary);
}
.card-value.success { color: var(--success); }
.card-value.warning { color: var(--warning); }
.card-value.danger { color: var(--danger); }

/* ========== 表格 ========== */
.table-wrap {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    background: #fafafa;
    font-weight: 600;
    font-size: 13px;
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--text-muted); padding: 40px; }
tr:hover td { background: #fafafa; }

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: flex-end;
    padding: 16px;
    gap: 4px;
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text);
}
.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}
.form-label .required {
    color: var(--danger);
    margin-right: 2px;
}
.form-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(22,119,255,0.15);
}
.form-input.error {
    border-color: var(--danger);
}
.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}
select.form-input {
    appearance: auto;
}
textarea.form-input {
    height: auto;
    padding: 8px 12px;
    resize: vertical;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 20px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    gap: 6px;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}
.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-default {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-default:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-sm {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 状态标签 ========== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.tag-pending { background: #fff7e6; color: #d46b08; }
.tag-active { background: #f6ffed; color: #389e0d; }
.tag-processing { background: #e6f4ff; color: #1677ff; }
.tag-danger { background: #fff2f0; color: #cf1322; }
.tag-disabled { background: #f5f5f5; color: #8c8c8c; }

/* ========== 时间线 ========== */
.timeline {
    padding: 0;
    list-style: none;
}
.timeline-item {
    position: relative;
    padding: 0 0 20px 24px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #e6f4ff;
}
.timeline-item::after {
    content: '';
    position: absolute;
    left: 9px;
    top: 16px;
    bottom: 0;
    width: 1px;
    background: var(--border);
}
.timeline-item:last-child::after {
    display: none;
}
.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
}
.timeline-event {
    font-size: 13px;
    margin-top: 2px;
}

/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    width: 520px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-close {
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    background: none;
    border: none;
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== 提示消息 ========== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease;
}
.toast-success { background: #f6ffed; color: #389e0d; border: 1px solid #b7eb8f; }
.toast-error { background: #fff2f0; color: #cf1322; border: 1px solid #ffa39e; }
.toast-info { background: #e6f4ff; color: #1677ff; border: 1px solid #91caff; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== 工具 ========== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-12 { gap: 12px; }
.gap-8 { gap: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 8px; }
.mt-8 { margin-top: 8px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.copy-btn {
    cursor: pointer;
    color: var(--primary);
    font-size: 12px;
    margin-left: 8px;
}

/* ========== 登录页 ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 40px;
    width: 400px;
    max-width: 90vw;
}
.login-title {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 32px;
    color: var(--text);
}
.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 24px;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar-logo { padding: 0 8px; font-size: 0; }
    .sidebar-menu .menu-item { padding: 10px 8px; justify-content: center; }
    .sidebar-menu .menu-item .menu-icon { margin-right: 0; }
    .sidebar-menu .menu-item span:not(.menu-icon) { display: none; }
    .sidebar-menu .menu-section { display: none; }
    .card-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .sidebar.mobile-open { display: flex; position: fixed; z-index: 100; height: 100vh; }
    .mobile-menu-btn { display: block !important; }
    .header { padding: 0 12px; }
    .content { padding: 12px; }
    .card-row { grid-template-columns: 1fr; }
    .flex-between { flex-direction: column; align-items: flex-start; gap: 8px; }
}
.mobile-menu-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }

/* ========== 邀请码区域 ========== */
.invite-code-area {
    background: linear-gradient(135deg, #f6ffed, #e6f4ff);
    border: 1px dashed #91caff;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}
.invite-code {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}
.empty-state-text {
    font-size: 14px;
}

/* ========== 搜索/筛选栏 ========== */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar .form-input {
    width: auto;
    min-width: 160px;
}

/* ========== 金额格式 ========== */
.amount { font-variant-numeric: tabular-nums; }
.amount::before { content: '¥'; margin-right: 2px; }