/* ============================================================
   支付宝服务商转账系统 - 管理后台样式
   ============================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

:root {
    --primary: #1677ff;
    --primary-hover: #4096ff;
    --primary-light: #e6f4ff;
    --success: #52c41a;
    --warning: #faad14;
    --error: #ff4d4f;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --bg: #f0f2f5;
    --card-bg: #fff;
    --sidebar-bg: #001529;
    --sidebar-text: #a6adb4;
    --sidebar-active: #1677ff;
}

/* ========== 登录页 ========== */
.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1677ff 0%, #001529 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 1000px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #1677ff 0%, #4096ff 100%);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand .logo {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.brand h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.brand p {
    opacity: 0.85;
    font-size: 15px;
}

.features {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.feature-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.feature-item h4 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.feature-item p {
    font-size: 13px;
    opacity: 0.8;
    line-height: 1.5;
}

.login-right {
    flex: 1;
    padding: 48px 40px;
    display: flex;
    align-items: center;
}

.login-box {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.login-box h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.form-group .required {
    color: var(--error);
    margin-left: 2px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 20px;
}

/* ========== 按钮 ========== */
.btn-primary, .btn-outline, .btn-text {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: #bfbfbf;
    cursor: not-allowed;
}

.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
}

.btn-text {
    background: transparent;
    color: var(--primary);
    padding: 6px 12px;
}

.btn-text:hover {
    background: var(--primary-light);
}

.btn-block {
    width: 100%;
    padding: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

.link-btn {
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

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

.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.sidebar-logo .logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}

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

.nav-item.active {
    color: #fff;
    background: var(--sidebar-active);
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

.user-tenant {
    color: var(--sidebar-text);
    font-size: 12px;
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    color: var(--sidebar-text);
    border-radius: 6px;
    transition: all 0.2s;
}

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

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

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

.topbar-left h2 {
    font-size: 18px;
    font-weight: 600;
}

.tenant-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.tenant-switcher select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}

.view-container {
    flex: 1;
    padding: 24px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* ========== 卡片/面板 ========== */
.panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}

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

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.panel-actions input,
.panel-actions select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}

.panel-body {
    padding: 20px;
}

/* ========== 统计卡片 ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.stat-trend {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--error); }

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

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

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text);
}

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

.data-table .empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.table-scroll {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.table-scroll .data-table {
    margin: 0;
}

/* ========== 状态标签 ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge.draft { background: #f0f0f0; color: #666; }
.badge.pending_confirmation { background: #fff7e6; color: #d48806; }
.badge.confirmed { background: #e6f4ff; color: #1677ff; }
.badge.executing { background: #e6f4ff; color: #1677ff; }
.badge.completed { background: #f6ffed; color: #52c41a; }
.badge.partial_failed { background: #fff7e6; color: #d48806; }
.badge.failed { background: #fff2f0; color: #ff4d4f; }
.badge.success { background: #f6ffed; color: #52c41a; }
/* 结果未知：既不是成功也不是失败，用橙色与前两者区分 */
.badge.unknown { background: #fff7e6; color: #d48806; border: 1px solid #ffd591; }
.badge.active { background: #f6ffed; color: #52c41a; }
.badge.pending { background: #e6f4ff; color: #1677ff; }
.badge.disabled { background: #f0f0f0; color: #999; }

.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-dot.success { background: var(--success); }
.status-dot.failed { background: var(--error); }
.status-dot.pending { background: var(--primary); }

/* ========== 操作按钮组 ========== */
.action-btns {
    display: flex;
    gap: 8px;
}

.action-btns a {
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
}

.action-btns a:hover {
    text-decoration: underline;
}

.action-btns a.danger {
    color: var(--error);
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

.pagination button {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination button:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== 详情页 ========== */
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.detail-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.detail-stat .label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.detail-stat .value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.detail-stat .value.success { color: var(--success); }
.detail-stat .value.error { color: var(--error); }

.mono {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 13px !important;
}

.amount {
    color: var(--primary);
    font-weight: 600;
}

/* ========== 上传区域 ========== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: border-color 0.2s;
    background: #fafafa;
}

/* 拖拽悬停高亮（与 .upload-area:hover 区分，表明"可放下"） */
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.12);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-tip p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ========== Tab 切换 ========== */
.tab-switch {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}

.tab-btn {
    padding: 8px 20px;
    background: #fff;
    border: none;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
}

.tab-btn:hover:not(.active) {
    background: var(--primary-light);
    color: var(--primary);
}

.tab-content {
    display: none;
    margin-top: 16px;
}

.tab-content.active {
    display: block;
}

/* ========== 手动输入 ========== */
.manual-input-area textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 13px;
    resize: vertical;
    line-height: 1.6;
}

.manual-input-area code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

/* ========== 表单操作栏 ========== */
.form-actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ========== 授权页面 ========== */
.auth-intro {
    background: var(--primary-light);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.auth-intro h4 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 15px;
}

.auth-intro ol {
    padding-left: 20px;
    color: var(--text-secondary);
    line-height: 2;
    font-size: 14px;
}

.auth-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.auth-result-box {
    background: #fafafa;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.auth-qr-wrapper {
    text-align: center;
}

.qr-placeholder {
    width: 200px;
    height: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.qr-big {
    width: 240px;
    height: 240px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
}

.qr-big img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.auth-url-wrapper {
    flex: 1;
}

.auth-url-wrapper label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.url-copy {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.url-copy input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: monospace;
    background: #fff;
}

.auth-tip {
    font-size: 13px;
    color: var(--text-secondary);
    background: #fffbe6;
    border: 1px solid #ffe58f;
    padding: 10px 12px;
    border-radius: 8px;
}

/* ========== 弹窗 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
}

.modal.show {
    display: block;
}

.modal-mask {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.qr-modal-wrapper {
    text-align: center;
}

.qr-info {
    background: #fafafa;
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
    text-align: left;
}

.qr-info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.qr-info-row .amount {
    font-size: 15px;
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.warning { background: #faad14; }

/* ========== 登录提示 ========== */
.login-tip {
    margin-top: 20px;
    padding: 10px 12px;
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    border-radius: 8px;
    font-size: 12px;
    color: #389e0d;
    text-align: center;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .login-container { flex-direction: column; }
    .login-left { padding: 32px 24px; }
    .features { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-stats { grid-template-columns: repeat(2, 1fr); }
    .sidebar { width: 64px; }
    .sidebar-logo span, .nav-item span:not(.nav-icon), .user-detail, .logout-btn { display: none; }
    .main-content { margin-left: 64px; }
    .auth-result-box { flex-direction: column; align-items: center; }
}

/* ========== 站点配置 ========== */
.settings-group {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}
.settings-group:last-child {
    border-bottom: none;
}
.settings-group-title {
    font-size: 16px;
    color: #1677ff;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e6f4ff;
}
.settings-group .form-group {
    margin-bottom: 20px;
}
.settings-group textarea {
    width: 100%;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    padding: 8px 12px;
    resize: vertical;
    min-height: 72px;
}
.settings-group textarea:focus {
    border-color: #1677ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(22,119,255,0.1);
}
