:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e6e9f2;
    --text: #1f2430;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --green: #16a34a;
    --blue: #2563eb;
    --gray: #6b7280;
    --red: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ============ 顶栏 ============ */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .5px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user { color: var(--text-muted); }

/* ============ 容器 ============ */
.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============ 统计卡片 ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.stat-green { border-left-color: var(--green); }
.stat-blue { border-left-color: var(--blue); }
.stat-gray { border-left-color: var(--gray); }
.stat-num { font-size: 30px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; }

/* ============ 面板 ============ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.panel-title { margin: 0 0 16px; font-size: 16px; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.panel-head .panel-title { margin: 0; }

/* ============ 表单 ============ */
.gen-form {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.field-grow { flex: 1; min-width: 180px; }
.field span { font-size: 13px; color: var(--text-muted); }

input[type="text"], input[type="password"], input[type="number"], select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.search-form { display: flex; gap: 8px; }
.search-form input { min-width: 220px; }

/* ============ 按钮 ============ */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, transform .05s, opacity .15s;
    background: #fff;
    color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2ff; color: var(--primary); }
.btn-secondary:hover { background: #e0e7ff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); border-color: #cbd2e0; }
.btn-danger { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 3px 10px; font-size: 12px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #fafbfe; color: var(--text-muted); font-weight: 600; font-size: 13px; }
tbody tr:hover { background: #fafbfe; }
.key { background: #f1f5f9; padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.empty { text-align: center; color: var(--text-muted); padding: 30px 0; }
.actions { display: flex; gap: 6px; }
.inline { display: inline; }

/* ============ 徽章 ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ============ 分页 ============ */
.pagination { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.page-link {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}
.page-link:hover { text-decoration: none; background: #f1f5f9; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ 提示 ============ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 4px;
}
.alert-success { background: #dcfce7; color: #15803d; }
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ============ 登录 / 安装页 ============ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.auth-title { margin: 0 0 4px; font-size: 24px; text-align: center; }
.auth-sub { text-align: center; color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 20px; }

/* ============ 演示页 ============ */
.hero { text-align: center; padding: 20px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 30px; }
.hero p { color: var(--text-muted); margin: 0; }
.api-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 860px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .api-grid { grid-template-columns: 1fr; }
}
.result-box {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 60px;
}
pre.docs {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 13px;
}
