/* ============================================================
 * 家庭照护智能工具 - 管理后台专用样式 (admin.css)
 * V4.24.1 — 统一管理后台 SPA 框架
 *
 * 设计理念：
 * - CSS Grid 布局：顶栏(56px) + 侧边栏(240px) + 内容区(flex:1) + 页脚(32px)
 * - 侧边栏折叠动画：240px ⇄ 64px
 * - 菜单树：可展开/折叠二级菜单，hover高亮，active选中态
 * - 复用 main.css 中原有的 .admin-* 业务样式（卡片/表格/按钮等）
 * ============================================================ */

:root {
    --admin-sidebar-width: 240px;
    --admin-sidebar-collapsed-width: 56px;
    --admin-topbar-height: 56px;
    --admin-footer-height: 32px;
    --admin-sidebar-bg: #1e293b;
    --admin-sidebar-hover: #334155;
    --admin-sidebar-active: #3b82f6;
    --admin-sidebar-text: #cbd5e1;
    --admin-sidebar-text-active: #ffffff;
    --admin-content-bg: #f1f5f9;
    --admin-card-bg: #ffffff;
    --admin-border: #e2e8f0;
    --admin-text-primary: #1e293b;
    --admin-text-secondary: #64748b;
    --admin-transition: 0.2s ease;
}

/* ============================================================
 * 全局重置（仅 admin.html 作用域）
 * ============================================================ */
#admin-page {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--admin-content-bg);
    color: var(--admin-text-primary);
    overflow: hidden;
    height: 100vh;
}

#admin-page .navbar,
#admin-page .hero-section,
#admin-page .tech-highlights,
#admin-page footer:not(#admin-footer),
#admin-page #mainContainer {
    display: none !important;
}

/* ============================================================
 * 主容器 - CSS Grid 布局
 * ============================================================ */
#admin-app {
    display: grid;
    grid-template-rows: var(--admin-topbar-height) 1fr var(--admin-footer-height);
    grid-template-columns: var(--admin-sidebar-width) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar content"
        "sidebar footer";
    height: 100vh;
    transition: grid-template-columns var(--admin-transition);
}

/* 侧边栏折叠 */
#admin-app.collapsed {
    grid-template-columns: var(--admin-sidebar-collapsed-width) 1fr;
}

/* ============================================================
 * 顶部栏
 * ============================================================ */
#admin-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--admin-topbar-height);
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--admin-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    color: var(--admin-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--admin-transition);
}
.topbar-toggle:hover {
    background: #e2e8f0;
}

.topbar-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--admin-text-primary);
}

.topbar-version {
    font-size: 11px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}

.topbar-center {
    flex: 0 0 auto;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    position: relative;
    transition: background var(--admin-transition);
}
.topbar-icon-btn:hover {
    background: #f1f5f9;
}

.topbar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background var(--admin-transition);
}
.topbar-user:hover {
    background: #f1f5f9;
}

.topbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient, linear-gradient(135deg, #3b82f6, #2563eb));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.topbar-user-name {
    font-size: 14px;
    color: var(--admin-text-primary);
}

.topbar-back-link {
    padding: 6px 14px;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--admin-text-secondary);
    text-decoration: none;
    transition: all var(--admin-transition);
}
.topbar-back-link:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

/* ============================================================
 * 消息下拉面板
 * ============================================================ */
.msg-dropdown {
    position: fixed;
    top: var(--admin-topbar-height);
    right: 100px;
    width: 360px;
    max-height: 480px;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 200;
    overflow: hidden;
}

.msg-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--admin-border);
}
.msg-dropdown-header h3 {
    margin: 0;
    font-size: 15px;
}

.msg-close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--admin-text-secondary);
}

.msg-dropdown-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.msg-empty {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 14px;
}

/* ============================================================
 * 侧边栏
 * ============================================================ */
#admin-sidebar {
    grid-area: sidebar;
    background: var(--admin-sidebar-bg);
    color: var(--admin-sidebar-text);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--admin-transition);
    width: var(--admin-sidebar-width);
}

#admin-app.collapsed #admin-sidebar {
    width: var(--admin-sidebar-collapsed-width);
}

#admin-menu {
    padding: 12px 0;
}

/* 菜单组 */
.menu-group {
    margin-bottom: 4px;
}

.menu-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.menu-group-header:hover {
    color: #94a3b8;
}

.menu-group-arrow {
    margin-left: auto;
    font-size: 9px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.menu-group.collapsed .menu-group-arrow {
    transform: rotate(-90deg);
}

.menu-group.collapsed .menu-children {
    max-height: 0 !important;
    opacity: 0;
}

#admin-app.collapsed .menu-group-header {
    justify-content: center;
    padding: 14px 8px 8px;
}
#admin-app.collapsed .menu-group-header .menu-group-label {
    display: none;
}

/* 菜单项 */
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--admin-sidebar-text);
    transition: all var(--admin-transition);
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    user-select: none;
}

.menu-item:hover {
    background: var(--admin-sidebar-hover);
    color: var(--admin-sidebar-text-active);
}

.menu-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--admin-sidebar-text-active);
    border-left-color: var(--admin-sidebar-active);
}

.menu-item .menu-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.menu-item .menu-label {
    flex: 1;
    min-width: 0;
}

.menu-item .menu-arrow {
    font-size: 10px;
    transition: transform var(--admin-transition);
    flex-shrink: 0;
}

.menu-item.expanded .menu-arrow {
    transform: rotate(90deg);
}

/* 子菜单容器 */
.menu-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.menu-children.open {
    max-height: 600px;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px 8px 54px;
    cursor: pointer;
    font-size: 13px;
    color: var(--admin-sidebar-text);
    transition: all var(--admin-transition);
    white-space: nowrap;
    overflow: hidden;
    border-left: 3px solid transparent;
}

.submenu-item:hover {
    background: var(--admin-sidebar-hover);
    color: var(--admin-sidebar-text-active);
}

.submenu-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--admin-sidebar-text-active);
    border-left-color: var(--admin-sidebar-active);
}

.submenu-item .submenu-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #64748b;
    flex-shrink: 0;
}

.submenu-item.active .submenu-dot {
    background: var(--admin-sidebar-active);
}

.submenu-item .submenu-badge {
    margin-left: auto;
    font-size: 10px;
    background: #f59e0b;
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

/* 折叠态子菜单 */
#admin-app.collapsed .menu-item .menu-label,
#admin-app.collapsed .menu-item .menu-arrow {
    display: none;
}
#admin-app.collapsed .menu-item {
    justify-content: center;
    padding: 12px 8px;
}
#admin-app.collapsed .menu-children,
#admin-app.collapsed .submenu-item {
    display: none;
}
#admin-app.collapsed .menu-group-header .menu-group-label,
#admin-app.collapsed .menu-group-header .menu-group-arrow {
    display: none;
}

/* ============================================================
 * 内容区
 * ============================================================ */
#admin-content {
    grid-area: content;
    overflow-y: auto;
    padding: 20px;
    background: var(--admin-content-bg);
}

#content-panel {
    min-height: calc(100vh - var(--admin-topbar-height) - var(--admin-footer-height) - 40px);
}

/* 页面标题（各模块可复用） */
.admin-page-header {
    margin-bottom: 20px;
}

.admin-page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--admin-text-primary);
    margin: 0 0 4px;
}

.admin-page-subtitle {
    font-size: 13px;
    color: var(--admin-text-secondary);
    margin: 0;
}

/* ============================================================
 * 加载状态 / 空状态
 * ============================================================ */
.content-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--admin-text-secondary);
}

.content-error {
    text-align: center;
    padding: 60px 20px;
    color: #ef4444;
}

.content-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

/* ============================================================
 * 页脚
 * ============================================================ */
#admin-footer {
    grid-area: footer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--admin-footer-height);
    font-size: 11px;
    color: #94a3b8;
    background: #fff;
    border-top: 1px solid var(--admin-border);
}

/* ============================================================
 * 响应式 — 平板/手机
 * ============================================================ */
@media (max-width: 768px) {
    #admin-app {
        grid-template-columns: 0 1fr;
    }
    #admin-app.collapsed {
        grid-template-columns: 0 1fr;
    }
    #admin-sidebar {
        position: fixed;
        top: var(--admin-topbar-height);
        left: 0;
        bottom: 0;
        z-index: 150;
        width: var(--admin-sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform var(--admin-transition);
    }
    #admin-app.mobile-sidebar-open #admin-sidebar {
        transform: translateX(0);
    }
    .topbar-back-link {
        font-size: 12px;
        padding: 4px 10px;
    }
    .topbar-user-name {
        display: none;
    }
}

/* ============================================================
 * 动画
 * ============================================================ */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.thinking-spinner {
    animation: spin 0.8s linear infinite;
}

/* ============================================================
 * 兼容现有 admin 模块样式（确保在 admin.html 中正确渲染）
 * ============================================================ */
#admin-content .admin-card {
    background: var(--admin-card-bg);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 20px;
    margin-bottom: 16px;
}

#admin-content .admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#admin-content .admin-table th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--admin-text-secondary);
    border-bottom: 2px solid var(--admin-border);
}

#admin-content .admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
}

#admin-content .admin-table tr:hover td {
    background: #f8fafc;
}

/* ============================================================
 * 全局按钮规范化 — 让 admin content 区内按钮风格统一
 * ============================================================ */
#admin-content button {
    font-family: inherit;
    transition: all var(--admin-transition);
}

/* ============================================================
 * 统一卡片头部样式（替代各模块内联 style）
 * ============================================================ */
.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--admin-border);
}

.admin-card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--admin-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
 * 统一 Tab 导航
 * ============================================================ */
.admin-tabs {
    display: flex;
    gap: 6px;
    background: #fff;
    padding: 6px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.admin-tab-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.admin-tab-btn:hover {
    background: #f1f5f9;
    color: #334155;
}
.admin-tab-btn.active {
    background: var(--primary-color, #3b82f6);
    color: #fff;
}

/* ============================================================
 * 统一按钮体系
 * ============================================================ */
.admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--admin-transition);
    background: #fff;
    color: var(--admin-text-secondary);
    white-space: nowrap;
    line-height: 1.4;
}
.admin-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.admin-btn-primary {
    background: var(--primary-color, #3b82f6);
    color: #fff;
    border-color: var(--primary-color, #3b82f6);
}
.admin-btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.admin-btn-success {
    background: #10b981;
    color: #fff;
    border-color: #10b981;
}
.admin-btn-success:hover {
    background: #059669;
    border-color: #059669;
}

.admin-btn-danger {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}
.admin-btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.admin-btn-warning {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}
.admin-btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

.admin-btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

.admin-btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
}

/* ============================================================
 * 统一统计卡片网格
 * ============================================================ */
.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
    transition: transform var(--admin-transition), box-shadow var(--admin-transition);
}
.admin-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.admin-stat-card-icon {
    font-size: 28px;
    margin-bottom: 8px;
    line-height: 1;
}

.admin-stat-card-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--admin-text-primary);
    margin-bottom: 4px;
    line-height: 1.2;
}

.admin-stat-card-label {
    font-size: 13px;
    color: var(--admin-text-secondary);
}

/* 彩色统计卡片变体 */
#admin-content .admin-stat-card-blue,
.admin-stat-card-blue {
    background: var(--primary-gradient, linear-gradient(135deg, #3b82f6, #2563eb));
    color: #fff;
}
#admin-content .admin-stat-card-green,
.admin-stat-card-green {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: #fff;
}
#admin-content .admin-stat-card-pink,
.admin-stat-card-pink {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: #fff;
}
#admin-content .admin-stat-card-cyan,
.admin-stat-card-cyan {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: #fff;
}
#admin-content .admin-stat-card-purple,
.admin-stat-card-purple {
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    color: #fff;
}
#admin-content .admin-stat-card-orange,
.admin-stat-card-orange {
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #fff;
}

#admin-content .admin-stat-card-blue .admin-stat-card-label,
#admin-content .admin-stat-card-green .admin-stat-card-label,
#admin-content .admin-stat-card-pink .admin-stat-card-label,
#admin-content .admin-stat-card-cyan .admin-stat-card-label,
#admin-content .admin-stat-card-purple .admin-stat-card-label,
#admin-content .admin-stat-card-orange .admin-stat-card-label,
.admin-stat-card-blue .admin-stat-card-label,
.admin-stat-card-green .admin-stat-card-label,
.admin-stat-card-pink .admin-stat-card-label,
.admin-stat-card-cyan .admin-stat-card-label,
.admin-stat-card-purple .admin-stat-card-label,
.admin-stat-card-orange .admin-stat-card-label {
    color: rgba(255,255,255,0.8);
}

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

.admin-data-table thead tr {
    background: #f8fafc;
}

.admin-data-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--admin-text-secondary);
    border-bottom: 2px solid var(--admin-border);
    white-space: nowrap;
}

.admin-data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--admin-text-primary);
}

.admin-data-table tbody tr:hover td {
    background: #f8fafc;
}

/* 表格滚动容器 */
.admin-table-scroll {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
}

.admin-table-scroll thead tr {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ============================================================
 * 统一标签/徽章
 * ============================================================ */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.admin-badge-success {
    background: #d1fae5;
    color: #065f46;
}

.admin-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.admin-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.admin-badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.admin-badge-neutral {
    background: #f3f4f6;
    color: #6b7280;
}

/* ============================================================
 * 统一列表项
 * ============================================================ */
.admin-list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.admin-list-item:hover {
    background: #f8fafc;
}
.admin-list-item:last-child {
    border-bottom: none;
}

/* ============================================================
 * 统一搜索栏
 * ============================================================ */
.admin-search-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--admin-border);
    background: #fff;
}

.admin-search-input {
    padding: 8px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    font-size: 13px;
    min-width: 200px;
    transition: border-color var(--admin-transition);
}
.admin-search-input:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============================================================
 * 统一工具栏
 * ============================================================ */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--admin-border);
}
.admin-toolbar-left,
.admin-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================
 * 统一表单控件
 * ============================================================ */
.admin-form-group {
    margin-bottom: 16px;
}

.admin-form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.admin-form-input,
.admin-form-select,
.admin-form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color var(--admin-transition);
}

.admin-form-input:focus,
.admin-form-select:focus,
.admin-form-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.admin-form-textarea {
    resize: vertical;
    min-height: 60px;
}

/* ============================================================
 * 统一提示/状态信息条
 * ============================================================ */
.admin-info-bar {
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.admin-info-bar-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #065f46;
}

.admin-info-bar-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.admin-info-bar-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.admin-info-bar-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* ============================================================
 * 统一弹窗/模态框
 * ============================================================ */
.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-modal-box {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

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

.admin-modal-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.admin-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--admin-text-secondary);
    padding: 4px;
    line-height: 1;
}
.admin-modal-close:hover {
    color: var(--admin-text-primary);
}

.admin-modal-body {
    padding: 20px;
}

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

#admin-content .admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#admin-content .admin-table th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--admin-text-secondary);
    border-bottom: 2px solid var(--admin-border);
}

#admin-content .admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
}

#admin-content .admin-table tr:hover td {
    background: #f8fafc;
}

/* ============================================================
 * 视觉润色 — 卡片微交互 & 响应式增强
 * ============================================================ */

/* 卡片 hover 微提升 */
#admin-content .admin-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#admin-content .admin-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* 彩色统计卡片的 hover 效果 */
#admin-content .admin-stat-card-blue:hover,
#admin-content .admin-stat-card-green:hover,
#admin-content .admin-stat-card-pink:hover,
#admin-content .admin-stat-card-cyan:hover,
#admin-content .admin-stat-card-purple:hover,
#admin-content .admin-stat-card-orange:hover,
.admin-stat-card-blue:hover,
.admin-stat-card-green:hover,
.admin-stat-card-pink:hover,
.admin-stat-card-cyan:hover,
.admin-stat-card-purple:hover,
.admin-stat-card-orange:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* 按钮 focus 环 */
.admin-btn:focus-visible {
    outline: 2px solid var(--primary-color, #3b82f6);
    outline-offset: 2px;
}

/* 响应式 — 统计网格 */
@media (max-width: 768px) {
    .admin-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .admin-data-table {
        font-size: 12px;
    }
    .admin-data-table th,
    .admin-data-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .admin-stat-grid {
        grid-template-columns: 1fr;
    }
    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-toolbar-left,
    .admin-toolbar-right {
        justify-content: center;
    }
}

/* 移动端表格横向滚动 */
@media (max-width: 640px) {
    .admin-table-scroll {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
 * 机构库管理 - 通用组件样式
 * ============================================================ */

/* 操作按钮容器 */
.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* 小按钮 */
.btn-small {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-small:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.btn-small.btn-danger {
    border-color: #fca5a5;
    color: #dc2626;
}
.btn-small.btn-danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
}
.btn-small.btn-warning {
    border-color: #fcd34d;
    color: #d97706;
}
.btn-small.btn-warning:hover {
    background: #fef3c7;
}
.btn-small.btn-success {
    border-color: #86efac;
    color: #059669;
}

/* 分页 */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 0;
    font-size: 13px;
    color: #6b7280;
}
.pagination-info {
    color: #9ca3af;
}
.page-info {
    font-weight: 500;
    color: #374151;
}
.btn-page {
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-page:hover {
    background: #f3f4f6;
    border-color: var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}

/* 大号模态框 */
.modal-large {
    max-width: 720px !important;
}

/* 详情网格 */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.detail-item {
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 8px;
}
.detail-item label {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-item span {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}
.detail-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}
.detail-section h4 {
    font-size: 15px;
    color: #374151;
    margin: 0 0 12px;
}

/* 管理页头部 */
.inst-admin-container,
.cg-admin-container,
.algo-admin-container {
    padding: 0;
}
.inst-admin-header,
.cg-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.inst-search-bar,
.cg-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.inst-search-bar input,
.inst-search-bar select,
.cg-search-bar input,
.cg-search-bar select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    min-width: 120px;
}
.inst-search-bar input:focus,
.inst-search-bar select:focus,
.cg-search-bar input:focus,
.cg-search-bar select:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.inst-header-actions,
.algo-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* 机构库头部 */
.inst-admin-header .btn-success,
.inst-admin-header .btn-outline,
.cg-admin-header .btn-success,
.algo-header-actions .btn-primary,
.algo-header-actions .btn-outline {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

/* ============================================================
 * 推荐算法配置页样式
 * ============================================================ */

.algo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.algo-header h3 {
    font-size: 20px;
    color: #1e293b;
    margin: 0;
}

/* ——— 公式英雄卡 ——— */
.algo-formula-hero {
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    border-radius: 14px;
    padding: 28px 32px;
    margin-bottom: 24px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.18);
}
.algo-formula-hero-title {
    font-size: 15px;
    color: #94a3b8;
    margin: 0 0 20px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.algo-formula-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.algo-formula-step {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    min-width: 100px;
}
.algo-formula-step.algo-formula-final {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}
.algo-formula-op {
    font-size: 20px;
    font-weight: 700;
    color: #64748b;
    padding: 0 12px;
    user-select: none;
}
.algo-formula-detail {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    line-height: 1.8;
    max-width: 680px;
    margin: 0 auto;
}
.algo-formula-detail code {
    display: inline-block;
    background: rgba(255,255,255,0.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #cbd5e1;
    margin: 0 2px;
}

.algo-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.algo-section {
    background: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border: 1px solid #e8ecf1;
    transition: box-shadow 0.2s;
}
.algo-section:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.algo-section h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 16px;
    color: #1e293b;
    margin: 0 0 20px;
    padding: 0 0 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    border-left: 4px solid #3b82f6;
    font-weight: 600;
    line-height: 1.3;
}
/* 分区颜色强调 */
.algo-section.accent-org   h4 { border-left-color: #f59e0b; }
.algo-section.accent-pay   h4 { border-left-color: #10b981; }
.algo-section.accent-dedup h4 { border-left-color: #8b5cf6; }
.algo-section.accent-ai    h4 { border-left-color: #ec4899; }

/* 行内紧凑开关（标题行右侧） */
.algo-toggle-inline {
    flex-shrink: 0;
    background: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    gap: 8px !important;
    min-height: auto !important;
    display: flex;
    flex-direction: row;
    align-items: center;
}
.algo-toggle-inline label {
    font-size: 12px !important;
    color: #94a3b8 !important;
    white-space: nowrap !important;
    word-break: normal !important;
    flex: 0 1 auto !important;
    line-height: 1 !important;
}

/* 子卡片标题也支持行内开关 */
.algo-subcard-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: #475569;
    margin: 0 0 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* 子卡片：用于机构附加分内的分组 */
.algo-subcard {
    background: #f8fafc;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 16px;
}
.algo-subcard:last-child {
    margin-bottom: 0;
}

/* 公式提示条 */
.algo-formula-banner {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 13px;
    color: #1e40af;
    gap: 8px;
}

.algo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}

.algo-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.algo-item label {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
    line-height: 1.3;
}
.algo-item input[type="number"],
.algo-item input[type="text"] {
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #1e293b;
}
.algo-item input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ——— Toggle 开关 ——— */
.algo-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f1f5f9;
    border-radius: 8px;
    gap: 16px;
    min-height: 44px;
}
.algo-toggle label {
    font-size: 13px;
    color: #374151;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
    word-break: break-all;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: background 0.25s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider {
    background: #3b82f6;
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ——— Footer ——— */
.algo-footer {
    display: flex;
    align-items: center;
    margin-top: 8px;
    padding: 20px 28px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.btn-large {
    padding: 12px 36px;
    font-size: 15px;
    font-weight: 600;
}

/* 响应式 */
@media (max-width: 640px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .algo-grid {
        grid-template-columns: 1fr;
    }
    .algo-section {
        padding: 18px 16px;
    }
    .algo-subcard {
        padding: 12px;
    }
    .algo-formula-hero {
        padding: 20px 16px;
    }
    .algo-formula-step {
        min-width: 70px;
        padding: 8px 12px;
        font-size: 12px;
    }
    .algo-formula-op {
        padding: 0 6px;
        font-size: 16px;
    }
    .inst-admin-header,
    .cg-admin-header {
        flex-direction: column;
        align-items: stretch;
    }
    .inst-search-bar,
    .cg-search-bar {
        flex-direction: column;
        align-items: stretch;
    }
}
