:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

.layout {
    display: flex;
    width: 100%;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: #0f172a;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-left: 8px;
}

.brand-icon {
    font-size: 26px;
    color: #38bdf8;
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.badge-free {
    font-size: 10px;
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: #1e293b;
    color: #ffffff;
}

.nav-item.active {
    background: var(--primary);
}

.count-badge {
    margin-left: auto;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid #1e293b;
}

.provider-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    max-width: 1400px;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.top-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: #0f172a;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 卡片与网格 */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.card h3 {
    font-size: 17px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.bg-blue { background: #dbeafe; color: #2563eb; }
.bg-green { background: #dcfce7; color: #16a34a; }
.bg-amber { background: #fef3c7; color: #d97706; }
.bg-purple { background: #f3e8ff; color: #9333ea; }

.stat-info .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* 渠道网格 */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.channel-card {
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 10px;
    background: #fafafa;
}

.channel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 15px;
}

.channel-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

.text-blue { color: #2563eb; }
.text-sky { color: #0284c7; }
.text-emerald { color: #059669; }

/* 状态徽章 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}

.status-badge.success {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.warning {
    background: #fef3c7;
    color: #b45309;
}

/* 表单与交互 */
.form-vertical {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.form-group input, .form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

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

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: #f1f5f9;
}

.drop-icon {
    font-size: 32px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.file-hint {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

/* 按钮 */
.btn {
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

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

.btn-secondary { background: #334155; color: #fff; }
.btn-secondary:hover { background: #1e293b; }

.btn-outline { background: transparent; border: 1px solid var(--border); color: #334155; }
.btn-outline:hover { background: #f1f5f9; }

.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 表格 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

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

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* 代码盒子 */
.code-box {
    background: #0f172a;
    color: #f8fafc;
    padding: 14px 16px;
    border-radius: 8px;
    margin-top: 10px;
    position: relative;
    font-family: Consolas, monospace;
    font-size: 13px;
    overflow-x: auto;
}

.code-box pre {
    white-space: pre-wrap;
    word-break: break-all;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

.step-list {
    margin-left: 20px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.kb-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
    max-height: 520px;
    overflow-y: auto;
}

.kb-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.kb-info strong {
    display: block;
    font-size: 14px;
    color: #1e293b;
}

.kb-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-delete {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

.btn-delete:hover {
    color: #b91c1c;
}

.result-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    min-height: 250px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.tab-pane {
    display: none;
}

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

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.badge-level {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-hot { background: #fee2e2; color: #b91c1c; }
.badge-high { background: #fef3c7; color: #b45309; }
.badge-medium { background: #e0f2fe; color: #0369a1; }


/* ==================== 登录弹窗与模态框样式 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay.active {
    display: flex;
}

.login-card {
    background: #ffffff;
    width: 400px;
    padding: 36px 32px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.login-icon {
    font-size: 42px;
    color: var(--primary);
    margin-bottom: 12px;
}

.login-brand h2 {
    font-size: 22px;
    color: #0f172a;
    font-weight: 700;
}

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

.login-hint {
    margin-top: 16px;
    text-align: center;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px dashed var(--border);
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* 模态框通用 */
.modal-card {
    background: #ffffff;
    width: 520px;
    max-width: 90vw;
    padding: 24px 28px;
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 18px;
    color: #0f172a;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

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

/* 顶部操作区与徽章 */
.site-selector-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.site-selector-box select {
    border: none;
    outline: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    background: transparent;
    cursor: pointer;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.badge-role {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.badge-role.super-admin {
    background: #fdf2f8;
    color: #db2777;
    border: 1px solid #fbcfe8;
}

.badge-role.tenant-admin {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.badge-role.agent {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.badge-domain {
    background: #f1f5f9;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #dc2626;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger-outline:hover {
    background: #fee2e2;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

code {
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
