/* ============================================================
   MedSearch API 控制台样式
   免构建原生实现，无外部依赖
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --bg: #f6f8fb;
    --card: #ffffff;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --border: #e5e9f0;
    --border-2: #cbd5e1;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warn: #d97706;
    --warn-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0891b2;
    --info-bg: #ecfeff;
    /* 胶囊风格：圆角一律走 pill / 大圆角，配柔和阴影，不留硬边 */
    --radius-pill: 999px;
    --radius: 16px;
    --radius-lg: 24px;
    --ring: 0 0 0 4px rgba(37, 99, 235, .12);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 4px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .12);
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC",
        "Microsoft YaHei", "PingFang SC", sans-serif;
    background:
        radial-gradient(900px 420px at 88% -8%, #e8efff 0%, transparent 60%),
        radial-gradient(700px 380px at -6% 4%, #eef6ff 0%, transparent 55%),
        var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); }

[hidden] { display: none !important; }

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .22);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--border-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); border-color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-pill); }
.btn-link {
    background: none; border: none; color: var(--primary);
    padding: 2px 4px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

.icon-btn {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: var(--text-2); padding: 7px 11px;
    border-radius: var(--radius-pill);
}
.icon-btn:hover { background: var(--bg); }

/* ==================== 表单 ==================== */
.field { display: block; margin-bottom: 14px; }
.field > span {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-2); margin-bottom: 6px;
}
.field > span em { font-style: normal; color: var(--faint); font-weight: 400; }
.field input, .field select, .field textarea,
.toolbar select,
.input {
    width: 100%; padding: 10px 18px; border: 1px solid var(--border-2);
    border-radius: var(--radius-pill); font-size: 14px; font-family: inherit;
    color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
/* 多行文本用大圆角，胶囊圆角在多行下会显得奇怪 */
.field textarea, textarea.input { border-radius: var(--radius); }
/* 原生 select 默认直角；去掉系统外观后才能吃到 pill 圆角 */
.field select, .toolbar select, select.input {
    padding-right: 34px;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1.2 1.5L6 6.3l4.8-4.8 1.2 1.2L6 8.7 0 2.7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    cursor: pointer;
}
.field input:focus, .field select:focus, .field textarea:focus,
.toolbar select:focus, .input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: var(--ring);
}
.field textarea { resize: vertical; min-height: 70px; }
.form-error {
    color: var(--danger); font-size: 13px; margin-bottom: 12px;
    min-height: 0; display: none;
}
.form-error.show { display: block; }

/* ==================== 认证屏 ==================== */
.auth-screen { display: flex; min-height: 100vh; }
.auth-brand {
    flex: 1 1 45%;
    background:
        radial-gradient(620px 320px at 18% 8%, rgba(255, 255, 255, .2), transparent 62%),
        linear-gradient(150deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
    color: #fff; display: flex; align-items: center; justify-content: center; padding: 40px;
}
.auth-brand-inner { max-width: 420px; }
.auth-brand .brand-logo { font-size: 48px; }
.auth-brand h1 { font-size: 2.1rem; margin: 14px 0 6px; }
.auth-brand .brand-sub { opacity: .85; font-size: 15px; margin-bottom: 34px; }
.brand-points { list-style: none; }
.brand-points li {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px; opacity: .95;
}
.brand-points .dot {
    width: 18px; height: 5px; border-radius: var(--radius-pill);
    background: #bfdbfe; flex-shrink: 0;
}
.auth-panel {
    flex: 1 1 55%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 40px 24px; background: #fff;
}
.auth-card {
    width: 100%; max-width: 400px; background: #fff;
    border: 1px solid var(--border); border-radius: 28px;
    padding: 26px 26px 28px; box-shadow: var(--shadow);
}
.auth-tabs {
    display: flex; gap: 4px; background: var(--bg); padding: 5px;
    border-radius: var(--radius-pill); margin-bottom: 26px;
}
.auth-tab {
    flex: 1; padding: 10px 14px; border: none; background: none;
    border-radius: var(--radius-pill);
    font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
    font-family: inherit; transition: all .15s;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.form-title { font-size: 22px; margin-bottom: 6px; }
.form-hint { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.form-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-foot-link { margin-top: 26px; font-size: 13px; color: var(--muted); }

/* ==================== 侧边栏 ==================== */
.app-screen { display: flex; min-height: 100vh; }
.sidebar {
    width: 200px; flex-shrink: 0; background: var(--sidebar-bg); color: #cbd5e1;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 7px; padding: 14px 12px;
    border-bottom: 1px solid #1e293b;
}
.sidebar-brand .brand-logo-sm { font-size: 20px; }
.sidebar-brand strong { display: block; color: #fff; font-size: 13.5px; }
.sidebar-brand small { color: #64748b; font-size: 11px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 6px; }
.nav-group {
    font-size: 10.5px; color: #475569; text-transform: uppercase;
    letter-spacing: .08em; padding: 10px 8px 5px; font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: 7px; padding: 8px 10px;
    border-radius: var(--radius-pill); color: #cbd5e1; font-size: 13px; cursor: pointer;
    margin-bottom: 2px; transition: all .15s; text-decoration: none;
}
.nav-item i { font-style: normal; font-size: 14px; width: 16px; text-align: center; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: #fff;
    font-weight: 500; box-shadow: 0 4px 14px rgba(37, 99, 235, .38);
}
.sidebar-foot { padding: 8px; border-top: 1px solid #1e293b; }
.sidebar-foot .btn { background: #1e293b; color: #cbd5e1; border-color: #334155; }
.sidebar-foot .btn:hover { background: #334155; color: #fff; }

/* ==================== 主区域 ==================== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 64px; background: rgba(255, 255, 255, .85);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px; padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; }
.menu-btn { display: none; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.quota-chip {
    display: inline-flex; align-items: baseline; gap: 4px;
    padding: 6px 14px; background: var(--primary-light);
    border-radius: var(--radius-pill); white-space: nowrap;
    font-size: 12px; color: var(--muted); line-height: 1.3;
    flex-shrink: 0; max-width: 100%;
}
.quota-chip-label { font-size: 12px; color: var(--muted); }
.quota-chip strong { font-size: 14px; color: var(--primary); font-weight: 600; }
.quota-chip.low { background: var(--danger-bg); }
.quota-chip.low strong { color: var(--danger); }
.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
    background: none; border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer; font-family: inherit;
}
.user-btn:hover { background: var(--bg); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.user-meta { text-align: left; line-height: 1.25; }
.user-name { display: block; font-size: 13px; font-weight: 500; }
.user-tier { display: block; font-size: 11px; color: var(--muted); }
.user-tier.pro { color: var(--warn); font-weight: 600; }
.caret { color: var(--faint); font-size: 11px; }
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); background: #fff;
    border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
    min-width: 190px; padding: 8px; z-index: 60;
}
.user-dropdown a {
    display: block; padding: 9px 14px; border-radius: var(--radius-pill);
    color: var(--text-2); font-size: 14px; cursor: pointer; margin: 2px 0;
}
.user-dropdown a:hover { background: var(--bg); text-decoration: none; }
.user-dropdown a.danger { color: var(--danger); }
.dropdown-email {
    padding: 8px 12px; font-size: 12px; color: var(--muted);
    border-bottom: 1px solid var(--border); margin-bottom: 4px;
    word-break: break-all;
}
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }

.view-wrap { flex: 1; padding: 24px; }
.view { max-width: 1180px; margin: 0 auto; }

/* ==================== 卡片 ==================== */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head .sub { font-size: 13px; color: var(--muted); font-weight: 400; }
.card-tight { padding: 16px; }

/* ==================== 统计卡 ==================== */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px; margin-bottom: 18px;
}
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px 22px; box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-label {
    font-size: 13px; color: var(--muted); margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
}
.stat-value { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat-value small { font-size: 14px; font-weight: 400; color: var(--muted); }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat.accent { border-color: var(--primary); background: var(--primary-light); }
.stat.accent .stat-value { color: var(--primary); }
.stat.warn { border-color: #fcd34d; background: var(--warn-bg); }
.stat.warn .stat-value { color: var(--warn); }
.stat.danger { border-color: #fca5a5; background: var(--danger-bg); }
.stat.danger .stat-value { color: var(--danger); }

/* ==================== 进度条 ==================== */
.progress {
    height: 9px; background: var(--border); border-radius: 999px;
    overflow: hidden; margin: 10px 0;
}
.progress-bar {
    height: 100%; background: var(--primary); border-radius: 999px;
    transition: width .4s ease;
}
.progress-bar.warn { background: var(--warn); }
.progress-bar.danger { background: var(--danger); }
.progress-legend {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--muted);
}

/* ==================== 徽章 ==================== */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
    border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: var(--bg); color: var(--muted); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ==================== 表格 ==================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
    background: var(--bg); text-align: left; padding: 11px 16px;
    font-weight: 600; color: var(--text-2); white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
/* 表头背景需要自己贴住容器圆角，表格没有 overflow 裁剪 */
table.data th:first-child { border-top-left-radius: calc(var(--radius-lg) - 1px); }
table.data th:last-child { border-top-right-radius: calc(var(--radius-lg) - 1px); }
table.data td {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfd; }
table.data th,
table.data td { text-align: left; }
table.data th.num,
table.data td.num {
    text-align: left; font-variant-numeric: tabular-nums;
    white-space: nowrap; font-feature-settings: "tnum";
}
table.data td.mono { font-family: var(--mono); font-size: 12.5px; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nowrap { white-space: nowrap; }

/* ==================== 工具条 ==================== */
.toolbar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-bottom: 16px;
}
.toolbar .input, .toolbar select { width: auto; min-width: 130px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.filter-label { font-size: 13px; color: var(--muted); }

/* ==================== 分页 ==================== */
.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-top: 16px; flex-wrap: wrap;
}
.pager-info { font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; gap: 6px; }

/* ==================== 空状态 ==================== */
.empty {
    text-align: center; padding: 52px 20px; color: var(--muted);
}
.empty-icon {
    font-size: 32px; margin: 0 auto 14px; width: 76px; height: 76px;
    border-radius: 50%; background: #fff; border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: center;
}
.empty-title { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto 16px; }

/* ==================== 骨架/加载 ==================== */
.loading { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }
.spinner {
    width: 22px; height: 22px; border: 2.5px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin .7s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 密钥 ==================== */
.key-list { display: flex; flex-direction: column; gap: 12px; }
.key-item {
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px 20px; display: flex; align-items: center;
    justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.key-item.revoked { opacity: .62; background: #fafbfd; }
.key-info { min-width: 0; flex: 1; }
.key-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.key-value {
    font-family: var(--mono); font-size: 12.5px; color: var(--muted);
    margin-top: 3px; word-break: break-all;
}
.key-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.key-item .meta { font-size: 12px; color: var(--faint); margin-top: 3px; }

.key-reveal-box {
    display: flex; align-items: center; gap: 10px; background: var(--bg);
    border: 1px solid var(--border-2); border-radius: var(--radius-lg);
    padding: 14px 18px; margin: 14px 0;
}
.key-reveal-box code {
    flex: 1; font-size: 13px; word-break: break-all; color: var(--text);
    background: none; padding: 0;
}

/* ==================== 趋势图 ==================== */
.chart {
    display: flex; align-items: flex-end; gap: 3px; height: 160px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.chart-col {
    flex: 1; min-width: 3px; display: flex; flex-direction: column;
    justify-content: flex-end; align-items: center; height: 100%;
    position: relative; cursor: default;
}
.chart-bar {
    width: 100%; background: linear-gradient(180deg, #60a5fa, #2563eb);
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
    min-height: 2px; transition: opacity .15s;
}
.chart-bar.has-fail {
    background: linear-gradient(to top,
        var(--danger) 0, var(--danger) var(--fail-h, 0%),
        var(--primary) var(--fail-h, 0%), var(--primary) 100%);
}
.chart-col:hover .chart-bar { opacity: .75; }
.chart-col::after {
    content: attr(data-tip); position: absolute; bottom: 100%;
    margin-bottom: 6px; background: #0f172a; color: #fff; font-size: 11px;
    padding: 5px 10px; border-radius: var(--radius-pill); white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5;
}
.chart-col:hover::after { opacity: 1; }
.chart-axis {
    display: flex; justify-content: space-between;
    font-size: 11px; color: var(--faint); margin-top: 6px;
}
.chart-legend {
    display: flex; gap: 16px; font-size: 12px;
    color: var(--muted); margin-top: 10px;
}
.chart-legend i {
    display: inline-block; width: 9px; height: 9px;
    border-radius: 2px; margin-right: 5px;
}

/* ==================== 订单 ==================== */
.order-pay-box {
    display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;
}
.order-qr {
    width: 180px; height: 180px; border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 10px; background: #fff; flex-shrink: 0;
}
.order-qr img { width: 100%; height: 100%; object-fit: contain; }
.order-pay-info { flex: 1; min-width: 260px; }
.order-amount { font-size: 30px; font-weight: 600; color: var(--danger); margin-bottom: 4px; }
.order-id-box {
    display: flex; align-items: center; gap: 10px; background: var(--primary-light);
    border: 1px solid #bfdbfe; border-radius: var(--radius-lg);
    padding: 13px 18px; margin: 12px 0;
}
.order-id-box code {
    font-size: 17px; font-weight: 600; letter-spacing: .06em; color: var(--primary-dark);
}
.steps { counter-reset: s; list-style: none; margin: 12px 0; }
.steps li {
    counter-increment: s; position: relative; padding-left: 30px;
    margin-bottom: 9px; font-size: 13.5px; color: var(--text-2);
}
.steps li::before {
    content: counter(s); position: absolute; left: 0; top: 1px;
    width: 20px; height: 20px; border-radius: 50%; background: var(--primary);
    color: #fff; font-size: 11px; display: flex; align-items: center;
    justify-content: center; font-weight: 600;
}

/* ==================== 检索结果 ==================== */
.search-box {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-row .main-input { flex: 1; min-width: 220px; font-size: 15px; padding: 12px 20px; }
.search-opts {
    display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px;
    font-size: 13px; color: var(--muted); align-items: center;
}
.search-opts label { display: flex; align-items: center; gap: 6px; }
.search-opts input, .search-opts select {
    padding: 6px 14px; border: 1px solid var(--border-2);
    border-radius: var(--radius-pill);
    font-size: 13px; font-family: inherit;
}
.search-opts input[type="number"] { width: 78px; }

.result-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.result-count { font-size: 14px; color: var(--text-2); }
.result-count strong { color: var(--primary); }

/* 文献篮：跨检索累加，体检/导出入口集中在这里 */
.basket-card { margin-bottom: 18px; }
.basket-hint {
    display: inline-block; margin-left: 10px;
    font-size: 12px; color: var(--muted); font-weight: 400;
}
.basket-ops { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.basket-empty { padding: 8px 0 4px; }
.basket-list {
    display: flex; flex-direction: column; gap: 0;
    max-height: 280px; overflow-y: auto;
    border-top: 1px solid var(--border); margin-top: 4px;
}
.basket-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 4px; border-bottom: 1px dashed var(--border);
}
.basket-item:last-child { border-bottom: none; }
.basket-idx {
    flex-shrink: 0; width: 22px; height: 22px; line-height: 22px;
    text-align: center; font-size: 12px; font-weight: 600;
    color: var(--primary); background: var(--primary-light);
    border-radius: var(--radius-pill);
}
.basket-body { flex: 1; min-width: 0; }
.basket-title {
    font-size: 13.5px; font-weight: 600; color: var(--text);
    line-height: 1.4; margin-bottom: 2px;
}
.basket-meta { font-size: 12px; color: var(--muted); }
.basket-meta em { font-style: normal; color: var(--text-2); font-weight: 500; }
.article.in-basket { border-color: #93c5fd; background: #f8fbff; }

.article-list { display: flex; flex-direction: column; gap: 12px; }
.article {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 18px 22px; box-shadow: var(--shadow);
    transition: border-color .15s, box-shadow .15s;
}
.article:hover { border-color: #bfdbfe; box-shadow: var(--shadow-lg); }
.article-head { display: flex; gap: 12px; align-items: flex-start; }
.article-check { margin-top: 3px; flex-shrink: 0; }
.article-title {
    font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.45;
    margin-bottom: 6px; cursor: pointer;
}
.article-title:hover { color: var(--primary); }
.article-authors { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.article-journal { font-size: 12.5px; color: var(--muted); }
.article-journal em { color: var(--text-2); font-weight: 500; font-style: normal; }
.article-abstract {
    font-size: 13.5px; color: var(--text-2); line-height: 1.7; margin-top: 10px;
    padding-top: 10px; border-top: 1px dashed var(--border);
}
.article-abstract.clamped {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden;
}
.article-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-top: 10px; flex-wrap: wrap;
}
.article-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.article-ops { display: flex; gap: 6px; flex-wrap: wrap; }
/* 来源标签：区分 PubMed / OpenAlex */
.src-tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius-pill, 999px); }
.src-pubmed { background: #e8f0fe; color: #1a56c4; }
.src-openalex { background: #fef3e8; color: #b8581a; }
/* 相关度展示 */
.rel-row { margin-top: 4px; }
.rel-badge {
    font-size: 11px; color: var(--muted); background: var(--bg);
    padding: 2px 8px; border-radius: var(--radius-pill, 999px); white-space: nowrap;
}
.citation-out {
    margin-top: 10px; background: var(--bg); border: 1px solid var(--border);
    border-left: 4px solid var(--primary); border-radius: var(--radius);
    padding: 12px 16px; font-size: 13px; line-height: 1.7; color: var(--text-2);
    word-break: break-word;
}

/* ==================== 文档 ==================== */
.doc-section { margin-bottom: 28px; }
.doc-section h2 {
    font-size: 18px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.doc-section > p { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.code-block {
    background: #0f172a; color: #e2e8f0; border-radius: var(--radius-lg);
    padding: 0; overflow: hidden; margin-bottom: 14px;
}
.code-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px; background: #1e293b; font-size: 12px; color: #94a3b8;
}
.code-head button {
    background: #334155; color: #e2e8f0; border: none;
    border-radius: var(--radius-pill);
    padding: 4px 14px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.code-head button:hover { background: #475569; }
.code-block pre {
    padding: 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.65;
    margin: 0; font-family: var(--mono);
}
.code-block .hl { color: #7dd3fc; }
.code-block .str { color: #86efac; }
.code-block .cm { color: #64748b; }
.endpoint-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 8px;
    background: #fff; flex-wrap: wrap;
}
.method {
    font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 3px 10px;
    border-radius: var(--radius-pill); background: var(--success-bg); color: var(--success);
}
.method.post { background: var(--primary-light); color: var(--primary); }
.endpoint-path { font-family: var(--mono); font-size: 13px; }
.endpoint-desc { font-size: 12.5px; color: var(--muted); margin-left: auto; }
.param-table { font-size: 13px; }
.param-table code {
    background: var(--bg); padding: 2px 9px;
    border-radius: var(--radius-pill); font-size: 12px;
}

/* ==================== 计划卡 ==================== */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.plan {
    border: 2px solid var(--border); border-radius: var(--radius-lg);
    padding: 26px 24px; text-align: center; position: relative; background: #fff;
    box-shadow: var(--shadow-sm); transition: all .15s;
}
.plan:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.plan.current { border-color: var(--primary); }
.plan.current::after {
    content: "当前套餐"; position: absolute; top: -11px; left: 50%;
    transform: translateX(-50%); background: var(--primary); color: #fff;
    padding: 2px 14px; border-radius: 999px; font-size: 12px;
}
.plan-name { font-size: 16px; font-weight: 600; }
.plan-price { font-size: 32px; font-weight: 700; margin: 10px 0; }
.plan-price small { font-size: 14px; font-weight: 400; color: var(--muted); }
.plan-features { list-style: none; text-align: left; margin: 16px 0; }
.plan-features li { padding: 6px 0; font-size: 13.5px; color: var(--text-2); }
.plan-features li::before { content: "✓"; color: var(--success); font-weight: 700; margin-right: 8px; }

/* ==================== 提示 ==================== */
.alert {
    padding: 14px 20px; border-radius: var(--radius-lg); font-size: 13.5px;
    margin-bottom: 16px; border: 1px solid;
}
.alert-info { background: var(--primary-light); border-color: #bfdbfe; color: #1e40af; }
.alert-warn { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.alert-danger { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert-success { background: var(--success-bg); border-color: #bbf7d0; color: #166534; }

/* ==================== 参考文献格式体检 ==================== */
/* 体检是这个产品最重要的转化钩子：让用户先免费看见「我的参考文献有问题」，
   才愿意为批量导出付费。所以报告要一眼能读出问题在哪一条，而不是一堆术语。 */
.audit-box {
    margin: 0 20px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: #fff; overflow: hidden;
}
.audit-head {
    display: flex; align-items: baseline; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-size: 14px; color: var(--text);
}
.audit-head .sub { font-size: 12px; color: var(--muted); }
.audit-free {
    padding: 9px 16px; background: var(--primary-light);
    font-size: 12.5px; color: #1e40af;
}
.audit-ok {
    padding: 16px; font-size: 13.5px; color: var(--success);
}
.audit-stat {
    display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px 4px;
}
.audit-pill {
    font-size: 12px; padding: 3px 10px; border-radius: var(--radius-pill);
    border: 1px solid transparent;
}
.audit-pill.error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.audit-pill.warn  { background: var(--warn-bg);   color: var(--warn);   border-color: #fde68a; }
.audit-pill.info  { background: var(--primary-light); color: var(--primary); border-color: #bfdbfe; }
.audit-pill.ok    { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.audit-list {
    max-height: 340px; overflow-y: auto; padding: 10px 16px 4px;
    border-top: 1px solid var(--border); margin-top: 8px;
}
.audit-item {
    display: flex; gap: 10px; padding: 9px 0;
    border-bottom: 1px dashed var(--border);
}
.audit-item:last-child { border-bottom: none; }
.audit-tag {
    flex: none; font-size: 11px; padding: 2px 8px; height: fit-content;
    border-radius: var(--radius-pill); white-space: nowrap;
}
.audit-error .audit-tag { background: var(--danger-bg); color: var(--danger); }
.audit-warn  .audit-tag { background: var(--warn-bg);   color: var(--warn); }
.audit-info  .audit-tag { background: var(--primary-light); color: var(--primary); }
.audit-body { min-width: 0; }
.audit-msg { font-size: 13px; color: var(--text); }
.audit-title {
    font-size: 12px; color: var(--muted); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.audit-fix { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.audit-missing {
    padding: 10px 16px; background: var(--warn-bg);
    font-size: 12.5px; color: #92400e;
}

/* ==================== Toast ==================== */
.toast-wrap {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
    align-items: center; pointer-events: none;
}
.toast {
    background: #0f172a; color: #fff; padding: 11px 24px;
    border-radius: var(--radius-pill);
    font-size: 14px; box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
    max-width: 80vw;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 弹窗 ==================== */
.modal-mask {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
    display: flex; align-items: center; justify-content: center; z-index: 9000;
    padding: 20px; backdrop-filter: blur(2px);
}
.modal {
    background: #fff; border-radius: 28px; width: 100%;
    max-width: 480px; box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease; max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}
.modal-head { padding: 18px 22px 0; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 14px 22px; font-size: 14px; color: var(--text-2); }
.modal-lead { margin-bottom: 4px; }
.modal-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.modal-foot { padding: 0 22px 20px; }
.modal-foot-split { display: flex; gap: 10px; justify-content: flex-end; }
.modal-body code {
    background: var(--bg); padding: 2px 9px;
    border-radius: var(--radius-pill); font-size: 12.5px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 900px) {
    .auth-screen { flex-direction: column; }
    .auth-brand { flex: none; padding: 32px 24px; }
    .auth-brand .brand-points { display: none; }
    .auth-panel { flex: none; }
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 100;
        transform: translateX(-100%); transition: transform .25s;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .menu-btn { display: block; }
    .view-wrap { padding: 16px; }
    .topbar { padding: 0 14px; height: 56px; gap: 10px; }
    .topbar-title { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-right { gap: 8px; flex-shrink: 0; }
    /* 窄屏保留配额，改成更紧的单行胶囊 */
    .quota-chip { padding: 4px 10px; font-size: 11px; gap: 3px; }
    .quota-chip-label { font-size: 11px; }
    .quota-chip strong { font-size: 13px; }
    table.data { font-size: 12.5px; }
    table.data th, table.data td { padding: 10px 12px; }
    .order-qr { width: 150px; height: 150px; }
}
@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 21px; }
    .user-meta { display: none; }
    .search-opts { gap: 8px; }
    .quota-chip-label { display: none; }
    .quota-chip { padding: 4px 9px; }
    .quota-chip strong { font-size: 13px; }
    .card { padding: 16px; }
    table.data th, table.data td { padding: 8px 10px; }
}
