/* =========================================================
 * 用户端全局样式（外联自原 header.php / footer.php 内联 <style>）
 * 包含：CSS 变量、布局、侧栏（含平滑折叠过渡）、卡片/表单/模态、
 *       Flash Toast、showToast、移动端紧凑化样式、全局进度条
 * ========================================================= */

:root {
    --bs-primary: #4671ff;
    --bs-primary-rgb: 70, 113, 255;
    --primary: var(--bs-primary);
    --primary-hover: #2d57e8;
    --primary-light: rgba(var(--bs-primary-rgb), 0.1);
    --surface: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
}

body {
    background: var(--surface);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

/* --- 登录/未授权页 --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
}

/* --- 仪表盘整体布局 --- */
.app-layout { min-height: 100vh; width: 100%; position: relative; }

.app-sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* PC 端侧边栏折叠状态（可动画化属性取代 display:none，整体 0.3s 同步） */
@media (min-width: 992px) {
    .app-sidebar { overflow-x: hidden; }

    /* === 元素自身过渡定义（仅 ≥992px 适用，避免与移动端 transform 冲突）=== */
    .app-sidebar .sidebar-brand {
        transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), justify-content 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-sidebar .sidebar-brand i,
    .app-sidebar .nav-item i {
        display: inline-block;
        transform-origin: center;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }
    .app-sidebar .sidebar-brand span,
    .app-sidebar .nav-item span,
    .app-sidebar .user-info {
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        max-width: 200px;
        opacity: 1;
        transition: opacity 0.18s ease, max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-sidebar .nav-label {
        overflow: hidden;
        max-height: 40px;
        opacity: 1;
        transition: opacity 0.18s ease, max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-sidebar .logout-btn {
        display: inline-block;
        overflow: hidden;
        max-width: 40px;
        opacity: 1;
        transition: opacity 0.18s ease, max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-sidebar .nav-item {
        transition: background-color 0.15s ease, color 0.15s ease, padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), justify-content 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-sidebar .user-card {
        transition: justify-content 0.3s cubic-bezier(0.4, 0, 0.2, 1), gap 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-main {
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: margin-left, width;
    }

    /* === 折叠态样式 === */
    .app-sidebar.collapsed,
    html.sb-collapsed .app-sidebar { width: 80px; }

    .app-sidebar.collapsed .sidebar-brand,
    html.sb-collapsed .app-sidebar .sidebar-brand { justify-content: center; padding: 0; }

    .app-sidebar.collapsed .sidebar-brand span,
    .app-sidebar.collapsed .nav-item span,
    .app-sidebar.collapsed .user-info,
    html.sb-collapsed .app-sidebar .sidebar-brand span,
    html.sb-collapsed .app-sidebar .nav-item span,
    html.sb-collapsed .app-sidebar .user-info {
        opacity: 0;
        max-width: 0;
        pointer-events: none;
    }

    .app-sidebar.collapsed .nav-label,
    html.sb-collapsed .app-sidebar .nav-label {
        opacity: 0;
        max-height: 0;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0;
        padding-bottom: 0;
        pointer-events: none;
    }

    .app-sidebar.collapsed .logout-btn,
    html.sb-collapsed .app-sidebar .logout-btn {
        opacity: 0;
        max-width: 0;
        pointer-events: none;
    }

    .app-sidebar.collapsed .sidebar-brand i,
    html.sb-collapsed .app-sidebar .sidebar-brand i { margin-right: 0; transform: scale(1.2); }

    .app-sidebar.collapsed .nav-item,
    html.sb-collapsed .app-sidebar .nav-item { justify-content: center; padding: 12px 0; }

    .app-sidebar.collapsed .nav-item i,
    html.sb-collapsed .app-sidebar .nav-item i { margin-right: 0; transform: scale(1.18); }

    .app-sidebar.collapsed .user-card,
    html.sb-collapsed .app-sidebar .user-card { justify-content: center; gap: 0; }

    .app-main.collapsed,
    html.sb-collapsed .app-main { margin-left: 80px; width: calc(100% - 80px); }
}

.sidebar-brand {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-brand i { color: var(--primary); font-size: 1.5rem; margin-right: 10px; }

.sidebar-nav {
    padding: 20px 16px;
    flex-grow: 1;
    overflow-y: auto;
}
.sidebar-nav .nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    font-weight: 700;
    margin: 16px 0 8px 12px;
}
.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar-nav .nav-item i { font-size: 1.1rem; margin-right: 12px; width: 20px; text-align: center; }
.sidebar-nav .nav-item:hover { background: #f8fafc; color: var(--primary); }
.sidebar-nav .nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    transition: none;
}
/* 点击后立即应用 active 视觉态，避免页面加载期出现 hover→active 二段渐变 */
.sidebar-nav .nav-item.nav-loading {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    transition: none;
}
.sidebar-nav .nav-item.text-danger:hover { background: #fef2f2; color: #ef4444 !important; }
.sidebar-nav .nav-item.text-danger.active { background: #fef2f2; color: #ef4444 !important; }
.sidebar-nav .nav-item.text-danger.nav-loading { background: #fef2f2; color: #ef4444 !important; }

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
}
.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem;
    flex-shrink: 0;
}
.user-info { flex-grow: 1; min-width: 0; }
.user-info .name { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.user-info .role { font-size: 0.75rem; color: var(--text-muted); }
.logout-btn { color: var(--text-muted); cursor: pointer; transition: color 0.2s; }
.logout-btn:hover { color: #ef4444; }

/* --- 主内容区 --- */
.app-main {
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.app-header {
    height: 72px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content { padding: 32px; flex-grow: 1; }

.sidebar-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.1); }
    .app-main { margin-left: 0; width: 100%; }
    .app-header { padding: 0 20px; }
    .app-content { padding: 20px 16px; overflow-x: hidden; }
}

/* --- 全局通用组件 --- */
.card {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    margin-bottom: 24px;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    font-weight: 700;
    font-size: 1.05rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-body { padding: 24px; }

.btn-primary { background: var(--primary); border: 0; font-weight: 500; border-radius: 8px; transition: all 0.2s; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(70,113,255,0.3); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); border-radius: 8px; font-weight: 500; }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-sm { border-radius: 8px; }

.form-control, .form-select { border-radius: 8px; border-color: var(--border-color); background: #f8fafc; padding: 10px 14px; font-size: 14px; }
.form-control:focus, .form-select:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(70,113,255,0.1); }
.form-label { font-weight: 500; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

.table { font-size: 14px; }
.table > :not(caption) > * > * { padding: 0.7rem 0.85rem; vertical-align: middle; }
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.table-hover tbody tr:hover { background: #f8fafc; }

.badge { font-weight: 500; }
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 18px 24px; }
.modal-title { font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 16px 24px; }
/* 确保长内容弹窗可滚动 */
.modal { -webkit-overflow-scrolling: touch; }

/* 统计卡片 */
.stat-card .stat-num { font-size: 1.75rem; font-weight: 700; color: var(--text-main); letter-spacing: -0.02em; }

/* --- Flash Toast (服务端闪存提示) ---
 * 背景色通过元素 style 属性按类型动态设置，此处仅定义结构样式
 */
.flash-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(0,0,0,.18);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    font-size: 14px;
    font-weight: 500;
    transform: translateX(120%);
    opacity: 0;
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .35s ease;
}
.flash-toast.show { transform: translateX(0); opacity: 1; }
.flash-toast.hide { transform: translateX(130%); opacity: 0; transition: transform .3s ease, opacity .3s ease; }
.flash-toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    padding: 0 0 0 4px;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

/* --- JS 动态 Toast (window.showToast) --- */
.js-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(0,0,0,.18);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    font-size: 14px;
    font-weight: 500;
    transform: translateX(120%);
    opacity: 0;
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .35s ease;
}
.js-toast.show { transform: translateX(0); opacity: 1; }
.js-toast.hide { transform: translateX(130%); opacity: 0; transition: transform .3s ease, opacity .3s ease; }

/* --- 全局顶部进度条 --- */
#__app_progress_bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #3b82f6 0%, #06b6d4 50%, #10b981 100%);
    z-index: 99999;
    transition: width .25s cubic-bezier(.4,0,.2,1), opacity .25s;
    box-shadow: 0 0 8px rgba(59,130,246,.45);
    pointer-events: none;
    opacity: 0;
}

/* --- 移动端：模态/表单/卡片紧凑化 --- */
@media (max-width: 767.98px) {
    .modal-body { padding: 16px; }
    .modal-header, .modal-footer { padding: 14px 16px; }
    .modal-title { font-size: 1rem; }
    .card-header {
        padding: 14px 16px !important;
        font-size: 1rem;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .card-header > h5 > div:first-child { display: none !important; }
    .card-header > h5 { font-size: 15px; flex: 0 1 auto; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .card-header > h5 .badge { padding: 4px 8px !important; font-size: .75rem; }
    .card-header .dropdown .btn { padding: 4px 8px !important; font-size: .78rem; }
    .card-header > :last-child { margin-left: auto; }
    /* card-header icon 缩小适配手机 */
    .card-header > div[style*="width:32px"]:first-child {
        width: 24px !important;
        height: 24px !important;
        margin-right: 8px !important;
        border-radius: 6px !important;
        font-size: .75rem;
        flex-shrink: 0;
    }
    /* profile card-header: icon 直接子元素，换行内容对齐文字起始位 */
    .card-header:has(> div[style*="width:32px"]:first-child) {
        padding-left: 48px !important;
    }
    .card-header:has(> div[style*="width:32px"]:first-child) > div[style*="width:32px"]:first-child {
        margin-left: -32px;
    }
    .card-body { padding: 16px; }
    .form-control, .form-select { font-size: 16px; padding: 10px 12px; } /* 16px 防 iOS 缩放 */
    .form-label { font-size: 13px; margin-bottom: 4px; }
    .table { font-size: 13px; }
    .table > :not(caption) > * > * { padding: 0.55rem 0.5rem; }
    .btn-sm { padding: .3rem .55rem; font-size: .8rem; }
    h4 { font-size: 1.2rem; }
    h5 { font-size: 1.05rem; }
    hr.my-2 { margin: 0.5rem 0 !important; }
}

/* ============================================================
 * 全局响应式流体方案（基于 clamp + viewport 自动缩放）
 * 适用所有用户端页面：标题 / 正文 / 表单 / 按钮 / 徽章 / 间距
 * 让屏幕越窄字号/间距越小，连续无跳变
 * ============================================================ */
@media (max-width: 767.98px) {
    /* 卡片头部图标（用户/管理员页常见的 32×32 圆角图标） */
    .card-header > div[style*="border-radius:8px"]:first-child,
    .card-header > div[style*="border-radius: 8px"]:first-child {
        width: clamp(22px, 6.5vw, 30px) !important;
        height: clamp(22px, 6.5vw, 30px) !important;
        margin-right: clamp(6px, 2vw, 10px) !important;
        font-size: clamp(.7rem, 2.4vw, .95rem);
        border-radius: 7px !important;
    }
    /* 卡片头部标题 */
    .card-header h5,
    .card-header h6,
    .card-header > h5,
    .card-header > h6 {
        font-size: clamp(.82rem, 3.4vw, 1rem) !important;
        line-height: 1.25;
    }
    /* 卡片正文常用文字 */
    .card-body .small,
    .card-body small,
    .card-body .form-label small,
    .card-body .form-text { font-size: clamp(.66rem, 2.4vw, .78rem); }
    .card-body .badge,
    .card-header .badge { font-size: clamp(.62rem, 2.2vw, .75rem); }
    .card-body .fw-bold.text-dark { font-size: clamp(.85rem, 2.8vw, 1rem); }

    /* 表单控件 / 按钮（避开 iOS 自动缩放，下限 16px=1rem） */
    .card-body .form-control,
    .card-body .form-select,
    .card-body .input-group .form-control {
        font-size: clamp(.85rem, 2.6vw, 1rem);
        padding: clamp(.4rem, 1.4vw, .55rem) clamp(.6rem, 2vw, .85rem);
    }
    .card-body .btn,
    .card-body .input-group .btn {
        font-size: clamp(.8rem, 2.6vw, .95rem);
        padding: clamp(.36rem, 1.3vw, .5rem) clamp(.7rem, 2.4vw, 1rem);
    }
    .btn-sm {
        font-size: clamp(.72rem, 2.3vw, .85rem) !important;
        padding: clamp(.26rem, 1vw, .35rem) clamp(.5rem, 1.8vw, .7rem) !important;
    }

    /* 表格文字 */
    .table { font-size: clamp(.74rem, 2.4vw, .85rem); }
    .table thead th { font-size: clamp(.62rem, 2vw, .72rem); }

    /* 标题文字 */
    h4 { font-size: clamp(1rem, 4vw, 1.25rem); }
    h5 { font-size: clamp(.92rem, 3.4vw, 1.1rem); }
    h6 { font-size: clamp(.85rem, 3vw, 1rem); }

    /* 卡片 / 行间距收紧 */
    .card { margin-bottom: clamp(.45rem, 2vw, .9rem); }
    .row.g-4 { --bs-gutter-y: clamp(.45rem, 1.8vw, .9rem); --bs-gutter-x: clamp(.45rem, 1.8vw, .9rem); }
    .row.g-3 { --bs-gutter-y: clamp(.4rem, 1.5vw, .75rem); --bs-gutter-x: clamp(.4rem, 1.5vw, .75rem); }
    .row.g-2 { --bs-gutter-y: clamp(.3rem, 1.2vw, .5rem); --bs-gutter-x: clamp(.3rem, 1.2vw, .5rem); }
}

/* ============================================================
 * 内联 style="font-size:..." 兜底流体化
 * 模板里大量硬编码内联字号会绕过外部 CSS，使用属性选择器 + !important
 * 在 ≤767.98px 小屏统一收紧（CSS 属性子串匹配是精确字符比对，不会误伤）
 * 同时覆盖 "无空格" 和 "有空格" 两种写法
 * ============================================================ */
@media (max-width: 767.98px) {
    [style*="font-size:.65rem"], [style*="font-size: .65rem"] { font-size: clamp(.55rem, 1.9vw, .65rem) !important; }
    [style*="font-size:.68rem"], [style*="font-size: .68rem"] { font-size: clamp(.56rem, 2vw, .68rem) !important; }
    [style*="font-size:.7rem"],  [style*="font-size: .7rem"]  { font-size: clamp(.58rem, 2vw, .7rem) !important; }
    [style*="font-size:.72rem"], [style*="font-size: .72rem"] { font-size: clamp(.6rem, 2.1vw, .72rem) !important; }
    [style*="font-size:.75rem"], [style*="font-size: .75rem"] { font-size: clamp(.62rem, 2.2vw, .75rem) !important; }
    [style*="font-size:.78rem"], [style*="font-size: .78rem"] { font-size: clamp(.64rem, 2.3vw, .78rem) !important; }
    [style*="font-size:.8rem"],  [style*="font-size: .8rem"]  { font-size: clamp(.66rem, 2.4vw, .8rem) !important; }
    [style*="font-size:.82rem"], [style*="font-size: .82rem"] { font-size: clamp(.68rem, 2.5vw, .82rem) !important; }
    [style*="font-size:.85rem"], [style*="font-size: .85rem"] { font-size: clamp(.7rem, 2.6vw, .85rem) !important; }
    [style*="font-size:.9rem"],  [style*="font-size: .9rem"]  { font-size: clamp(.74rem, 2.8vw, .9rem) !important; }
    [style*="font-size:.95rem"], [style*="font-size: .95rem"] { font-size: clamp(.78rem, 2.9vw, .95rem) !important; }
    [style*="font-size:1rem"],   [style*="font-size: 1rem"]   { font-size: clamp(.82rem, 3vw, 1rem) !important; }
    [style*="font-size:1.05rem"],[style*="font-size: 1.05rem"]{ font-size: clamp(.85rem, 3.2vw, 1.05rem) !important; }
    [style*="font-size:1.1rem"], [style*="font-size: 1.1rem"] { font-size: clamp(.88rem, 3.4vw, 1.1rem) !important; }

    /* dashboard 统计数字 */
    .stat-card .stat-num { font-size: clamp(1.05rem, 4.5vw, 1.75rem); }
    .stat-card-pretty .stat-num { font-size: clamp(.95rem, 4vw, 1.6rem) !important; }
    .stat-card-pretty .stat-label { font-size: clamp(.65rem, 2.4vw, .82rem) !important; }
    .stat-card-pretty .stat-icon { width: clamp(32px, 8vw, 52px) !important; height: clamp(32px, 8vw, 52px) !important; font-size: clamp(.95rem, 3.5vw, 1.5rem) !important; }
    .stat-card-pretty .stat-body { padding: clamp(8px, 2.5vw, 20px) !important; gap: clamp(6px, 2vw, 16px) !important; }

    /* 内联 px 字号兜底（模板/JS 大量使用 9~20px） */
    [style*="font-size:9px"],   [style*="font-size: 9px"]   { font-size: clamp(8px, 2vw, 9px) !important; }
    [style*="font-size:10px"],  [style*="font-size: 10px"]  { font-size: clamp(8.5px, 2.2vw, 10px) !important; }
    [style*="font-size:11px"],  [style*="font-size: 11px"]  { font-size: clamp(9px, 2.4vw, 11px) !important; }
    [style*="font-size:12px"],  [style*="font-size: 12px"]  { font-size: clamp(10px, 2.6vw, 12px) !important; }
    [style*="font-size:13px"],  [style*="font-size: 13px"]  { font-size: clamp(10.5px, 2.8vw, 13px) !important; }
    [style*="font-size:14px"],  [style*="font-size: 14px"]  { font-size: clamp(11px, 3vw, 14px) !important; }
    [style*="font-size:15px"],  [style*="font-size: 15px"]  { font-size: clamp(11.5px, 3.2vw, 15px) !important; }
    [style*="font-size:16px"],  [style*="font-size: 16px"]  { font-size: clamp(12px, 3.4vw, 16px) !important; }
    [style*="font-size:18px"],  [style*="font-size: 18px"]  { font-size: clamp(13px, 3.8vw, 18px) !important; }
    [style*="font-size:20px"],  [style*="font-size: 20px"]  { font-size: clamp(14px, 4.2vw, 20px) !important; }
    [style*="font-size:24px"],  [style*="font-size: 24px"]  { font-size: clamp(16px, 5vw, 24px) !important; }
    [style*="font-size:28px"],  [style*="font-size: 28px"]  { font-size: clamp(18px, 5.8vw, 28px) !important; }
    [style*="font-size:32px"],  [style*="font-size: 32px"]  { font-size: clamp(20px, 6.5vw, 32px) !important; }
    [style*="font-size:48px"],  [style*="font-size: 48px"]  { font-size: clamp(28px, 9vw, 48px) !important; }
    [style*="font-size:64px"],  [style*="font-size: 64px"]  { font-size: clamp(36px, 12vw, 64px) !important; }
}

/* ============================================================
   统一分页组件 (.pg-wrap)
   ============================================================ */
.pg-wrap {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #e2e8f0);
}
.pg-wrap .pg-info {
    font-size: .82rem;
    color: var(--text-muted, #64748b);
    text-align: center;
    line-height: 1.6;
}
.pg-wrap .pg-info strong {
    color: var(--text-main, #0f172a);
    font-weight: 700;
    margin: 0 2px;
}
.pg-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
}
.pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    background: #fff;
    color: var(--text-main, #0f172a);
    border: 1px solid var(--border-color, #e2e8f0);
    font-size: .82rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    user-select: none;
    transition: all .18s ease;
    cursor: pointer;
}
.pg-btn.icon {
    padding: 0;
    width: 34px;
    color: var(--text-muted, #64748b);
    font-weight: 500;
}
.pg-btn.icon i { font-size: .82rem; }
.pg-btn:hover:not(.disabled):not(.active) {
    background: var(--primary-light, rgba(70,113,255,.08));
    color: var(--primary, #4671ff);
    border-color: var(--primary, #4671ff);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(70,113,255,.15);
}
.pg-btn.active {
    background: var(--primary, #4671ff);
    color: #fff;
    border-color: var(--primary, #4671ff);
    box-shadow: 0 2px 6px rgba(70,113,255,.32);
    cursor: default;
}
.pg-btn.disabled {
    color: #cbd5e1;
    background: #fafbfc;
    border-color: #eef0f4;
    cursor: not-allowed;
    pointer-events: none;
}
.pg-btn.ellipsis {
    border: none;
    background: transparent;
    color: var(--text-muted, #64748b);
    min-width: 24px;
    cursor: default;
    pointer-events: none;
}
@media (min-width: 768px) {
    .pg-wrap {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .pg-wrap .pg-info { text-align: left; }
}


/* 
   统一分页组件 (renderPagination)
   桌面：左统计 + 右分页（智能省略号）
   移动：上下两行，仅显示当前页 X/Y + 上下页
    */
.pg-wrap{
  display:flex;flex-direction:column;gap:.5rem;
  margin-top:1rem;align-items:flex-end;
}
@media(min-width:576px){
  .pg-wrap{flex-direction:row;justify-content:space-between;align-items:center;}
}
.pg-info{
  font-size:.8125rem;color:#6c757d;line-height:1.5;
  text-align:right;
}
.pg-info strong{color:#212529;font-weight:600;}
@media(min-width:576px){.pg-info{text-align:left;}}

.pg-nav{display:block;}
.pg-list{
  list-style:none;margin:0;padding:0;
  display:flex;align-items:center;gap:.25rem;
  flex-wrap:nowrap;
}
.pg-item{display:flex;}
.pg-link{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:36px;height:36px;padding:0 .625rem;
  border-radius:10px;
  background:#fff;
  color:#495057;
  font-size:.875rem;font-weight:500;
  text-decoration:none;
  border:1px solid #e9ecef;
  transition:all .18s ease;
  user-select:none;
  line-height:1;
}
.pg-link:hover{
  background:#f1f5ff;color:#0d6efd;
  border-color:#cfe0ff;
  transform:translateY(-1px);
}
.pg-item.is-active .pg-link{
  background:linear-gradient(135deg,#0d6efd,#0a58ca);
  color:#fff;border-color:transparent;
  box-shadow:0 4px 12px rgba(13,110,253,.28);
  cursor:default;font-weight:600;
}
.pg-item.is-active .pg-link:hover{transform:none;}
.pg-item.is-disabled .pg-link{
  background:#f8f9fa;color:#adb5bd;
  border-color:#e9ecef;pointer-events:none;opacity:.6;
}
.pg-arrow .pg-link i{font-size:.875rem;}
.pg-ellipsis .pg-link{
  border-color:transparent;background:transparent;
  pointer-events:none;color:#adb5bd;
  padding:0 .25rem;min-width:24px;
}
.pg-ellipsis .pg-link:hover{transform:none;}
.pg-frac .pg-link{
  border-color:transparent;background:transparent;
  pointer-events:none;color:#6c757d;
  padding:0 .25rem;min-width:auto;font-weight:400;
}
.pg-frac .pg-link:hover{transform:none;}

/* 移动端：当前页加亮 */
@media(max-width:575.98px){
  .pg-link{min-width:40px;height:40px;border-radius:12px;}
  .pg-list{gap:.375rem;}
}

/* 暗色主题兼容（如已有 .dark-mode） */
@media (prefers-color-scheme: dark){
  .pg-link{background:#1f2937;border-color:#374151;color:#d1d5db;}
  .pg-link:hover{background:#1e3a8a33;color:#93c5fd;border-color:#1e40af;}
  .pg-item.is-disabled .pg-link{background:#111827;color:#6b7280;}
  .pg-info{color:#9ca3af;}
  .pg-info strong{color:#f3f4f6;}
}


/* 
   \u5168\u5c40\u6eda\u52a8\u6761 - \u5b8c\u5168\u9690\u85cf\uff08\u4fdd\u7559\u6eda\u52a8\u80fd\u529b\uff09
   Firefox / Chrome / Edge / Safari \u5168\u517c\u5bb9
    */
* {
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE 10+ */
}
*::-webkit-scrollbar,
*::-webkit-scrollbar-button,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-corner {
  display: none !important;       /* Chrome / Edge / Safari */
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* ============================================================
 * 跨域图片加载骨架屏（Skeleton/Shimmer）
 * 实现：CSS 背景动画做加载占位，JS 在 onload 后加 .skel-done 关闭动画
 * 使用：JS 自动给所有跨域 <img> 加 .skel-loading 类
 * ============================================================ */
.skel-loading {
  background-color: #f3f4f6;
  background-image: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.78) 50%, transparent 70%);
  background-size: 250% 100%;
  background-repeat: no-repeat;
  background-position: -150% 0;
  animation: skel-shimmer 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  transition: background-color 0.45s ease-out, background-image 0.45s ease-out;
  overflow: hidden;
  contain: paint;
  transform: translateZ(0);
}
.skel-loading.skel-done {
  background-color: transparent;
  background-image: none;
  animation: none;
}
.skel-img-pending {
  opacity: 0;
}
.hist-thumb-wrap img,
.hist-thumb img,
.link-card-thumb img,
.gal-thumb img,
.dead-card-thumb img,
.detail-img-wrap img,
.card-img-top img {
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
}
@keyframes skel-shimmer {
  0%   { background-position: -150% 0; }
  100% { background-position: 250% 0; }
}

/* —— 用户端移动端：card-header 强行单排、允许收缩 —— */
@media (max-width: 767.98px) {
    .card-header {
        padding: 14px 14px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }
    .card-header > h5 {
        font-size: .95rem !important;
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: flex !important;
        align-items: center !important;
    }
    .card-header > h5 > div[style*="border-radius:8px"] {
        width: 28px !important;
        height: 28px !important;
        font-size: .85rem;
        flex-shrink: 0 !important;
    }
    .card-header > h5 .badge {
        font-size: .72rem !important;
        padding: 2px 8px !important;
        flex-shrink: 0 !important;
    }
    /* 顶部按钮工具条 - 强行单排、允许收缩 */
    .card-header .d-flex.gap-2.align-items-center,
    .card-header .d-flex.align-items-center.gap-2,
    .card-header .iface-toolbar-actions,
    .card-header .users-toolbar-actions {
        flex-wrap: nowrap !important;
        overflow-x: visible !important;
        gap: 4px !important;
        flex-shrink: 1 !important;
        min-width: 0 !important;
    }
    .card-header .d-flex.gap-2.align-items-center::-webkit-scrollbar,
    .card-header .d-flex.align-items-center.gap-2::-webkit-scrollbar,
    .card-header .iface-toolbar-actions::-webkit-scrollbar,
    .card-header .users-toolbar-actions::-webkit-scrollbar { display: none; }
    .card-header .d-flex.gap-2.align-items-center > div[role="group"] > a,
    .card-header .d-flex.align-items-center.gap-2 > div[role="group"] > a,
    .card-header .iface-toolbar-actions > div[role="group"] > a,
    .card-header .users-toolbar-actions > div[role="group"] > a,
    .card-header div[role="group"] > a,
    .card-header div[aria-label="视图切换"] > a {
        width: 30px !important;
        height: 30px !important;
        flex-shrink: 1 !important;
    }
    .card-header .d-flex.gap-2.align-items-center > .btn,
    .card-header .d-flex.align-items-center.gap-2 > .btn,
    .card-header .iface-toolbar-actions > .btn,
    .card-header .users-toolbar-actions > .btn {
        height: 30px;
        min-width: 30px;
        padding: 0 10px;
        font-size: .75rem;
        flex-shrink: 1 !important;
        border-radius: 999px;
    }
}

/* 顶部操作按钮响应式（手机端变更小圆形图标，与视图切换按钮一致） */
@media (max-width: 575.98px) {
    .btn-action-circle,
    .card-header .d-flex.gap-2.align-items-center > div[role="group"] > a,
    .card-header .d-flex.align-items-center.gap-2 > div[role="group"] > a,
    .card-header .iface-toolbar-actions > div[role="group"] > a,
    .card-header .users-toolbar-actions > div[role="group"] > a,
    .card-header div[role="group"] > a,
    .card-header div[aria-label="视图切换"] > a {
        width: 28px !important;
        height: 28px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
    }
    .btn-action-circle i,
    .card-header .d-flex.gap-2.align-items-center > div[role="group"] > a i,
    .card-header .d-flex.align-items-center.gap-2 > div[role="group"] > a i,
    .card-header .iface-toolbar-actions > div[role="group"] > a i,
    .card-header .users-toolbar-actions > div[role="group"] > a i,
    .card-header div[role="group"] > a i,
    .card-header div[aria-label="视图切换"] > a i {
        font-size: 0.8rem !important;
    }
}