/* ========================================
 * 单游戏数据上报管理系统 - 样式表
 * 主色：#1677ff  背景：#f0f2f5
 * ======================================== */

/* CSS 变量定义 */
:root {
    --primary: #1677ff;
    --primary-hover: #4096ff;
    --primary-active: #0958d9;
    --primary-bg: rgba(22, 119, 255, 0.08);
    --success: #52c41a;
    --error: #ff4d4f;
    --warning: #faad14;
    --bg: #f0f2f5;
    --bg-hover: #f5f7fa;
    --sidebar-bg: #001529;

    --text-main: #333;
    --text-secondary: #666;
    --text-light: #999;

    --border: #e8e8e8;
    --border-light: #f0f0f0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg);
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-hover);
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ========================================
 * 整体布局
 * ======================================== */

/* 侧边栏：固定左侧，宽180px（名称已精简为2字） */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 180px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow: hidden;
}

/* 侧边栏头部 */
.sidebar-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 侧边栏菜单 */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 14px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s;
}

.sidebar-menu li a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-menu li.active a {
    background: var(--primary);
    color: #fff;
}

/* 菜单图标：蓝色#1677ff，选中时白色 */
.menu-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.sidebar-menu li.active .menu-icon {
    color: #fff;
}

.menu-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.menu-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 菜单分隔线 */
.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 16px;
}

/* 侧边栏遮罩层（移动端） */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

/* 主内容区 */
.main-content {
    margin-left: 180px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* 顶部栏：固定高度56px */
.top-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 56px;
    background: #fff;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-main);
    border-radius: 4px;
}

.menu-toggle svg {
    width: 22px;
    height: 22px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

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

/* 用户下拉菜单（hover 展开） */
.user-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: var(--text-secondary);
    user-select: none;
}

.user-menu:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.user-menu .user-name {
    font-size: 14px;
    color: inherit;
    font-weight: 500;
}

.user-caret {
    font-size: 10px;
    color: inherit;
    opacity: 0.7;
    transition: transform 0.2s ease;
    line-height: 1;
    margin-top: 2px;
}

.user-menu:hover .user-caret {
    transform: rotate(180deg);
    opacity: 1;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 21, 41, 0.12), 0 2px 8px rgba(0, 21, 41, 0.06);
    list-style: none;
    padding: 6px;
    margin: 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    border: 1px solid var(--border-light);
}

/* hover 展开：父容器 hover 或下拉本身 hover 都保持显示 */
.user-menu:hover > .user-dropdown,
.user-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 小三角指示器 */
.user-dropdown::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid var(--border-light);
    border-top: 1px solid var(--border-light);
    transform: rotate(45deg);
}

.user-dropdown li {
    margin: 0;
}

.user-dropdown li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-main);
    font-size: 14px;
    transition: background-color 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.user-dropdown li a:hover {
    background-color: var(--primary-bg);
    color: var(--primary);
}

.user-dropdown li.active a {
    background-color: var(--primary-bg);
    color: var(--primary);
    font-weight: 500;
}

.dropdown-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    flex-shrink: 0;
}

.dropdown-icon svg {
    width: 16px;
    height: 16px;
}

.dropdown-text {
    flex: 1;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 6px 4px !important;
}

.user-dropdown li.dropdown-logout a {
    color: var(--error);
}

.user-dropdown li.dropdown-logout a:hover {
    background-color: #fff1f0;
    color: #d4380d;
}

.user-dropdown li.dropdown-logout .dropdown-icon svg {
    stroke: var(--error);
}

.user-dropdown li.dropdown-logout a:hover .dropdown-icon svg {
    stroke: #d4380d;
}

/* 旧 logout-link 保留定义但不使用（兼容已删除 DOM，避免历史样式冲突） */
.logout-link {
    display: none;
}

/* 内容区 */
.content {
    flex: 1;
    padding: 0 24px 24px 24px;
}

/* ========================================
 * 卡片
 * ======================================== */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

/* 筛选栏默认隐藏，由 JS 控制显示 */
.filter-bar {
    display: block;
    margin-bottom: 0;
    background: #fff;
    box-shadow: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    margin-left: -24px;
    margin-right: -24px;
}

.filter-bar .card-body {
    padding: 8px 24px;
}

.filter-bar.filter-collapsed {
    display: none;
}

/* 筛选栏展开时，下方工具栏紧凑衔接 */
.filter-bar + .toolbar {
    margin-top: 12px;
}

/* 筛选栏紧凑布局：标题在左、输入框缩小、按钮放最后 */
.filter-bar form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}
.filter-bar .form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.filter-bar .form-row .form-group {
    display: flex;
    align-items: center;
    gap: 0;
    flex: none;
    margin-bottom: 0;
}
.filter-bar .form-row .form-label {
    display: none;
}
.filter-bar .form-row .form-input,
.filter-bar .form-row .form-select {
    width: 200px;
    height: 32px;
    padding: 0 10px;
    line-height: 30px;
    flex: none;
    font-size: 14px;
    box-sizing: border-box;
}
.filter-bar .filter-btns {
    display: flex;
    gap: 8px;
    flex: none;
}
.filter-bar .filter-btns .btn {
    height: 32px;
    padding: 0 18px;
    font-size: 14px;
    line-height: 30px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.card-body {
    padding: 24px;
}

/* 卡片内信息列表 */
.info-list {
    display: flex;
    flex-direction: column;
}

.info-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-item:first-child {
    padding-top: 0;
}

.info-item-label {
    width: 180px;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #666);
}

.info-item-value {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-main, #333);
}

/* 卡片网格布局（设置页用） */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.card-grid .card {
    margin-bottom: 0;
}

.card-grid .card-full {
    grid-column: 1 / -1;
}

@media (max-width: 992px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
 * 工具栏
 * ======================================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========================================
 * 按钮
 * ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    font-size: 14px;
    line-height: 1;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

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

.btn-danger {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

.btn-danger:hover {
    background: #ff7875;
    border-color: #ff7875;
    color: #fff;
}

.btn-sm {
    padding: 2px 6px;
    font-size: 10px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    padding: 6px 8px;
    font-size: 13px;
    color: #666;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.btn-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* ========================================
 * 列显示控制
 * ======================================== */
.column-control {
    position: relative;
}

.column-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    min-width: 140px;
    z-index: 100;
}

.column-dropdown.show {
    display: block;
}

.column-dropdown label {
    display: block;
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
}

.column-dropdown label:hover {
    background: #f5f5f5;
}

.column-dropdown label input {
    margin-right: 6px;
    vertical-align: middle;
}

/* ========================================
 * 导出对话框
 * ======================================== */
.export-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.export-dialog-content {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 200px;
    position: absolute;
    border: 1px solid var(--border);
    z-index: 10000;
}

.export-dialog h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
}

.export-option {
    padding: 8px 10px;
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.export-option:hover {
    background: #f5f5f5;
}

.export-option.selected {
    background: #e6f7ff;
    color: var(--primary);
}

.export-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.export-actions .btn {
    flex: 1;
}

/* ========================================
 * 表单
 * ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

.form-label.required::before {
    content: '*';
    color: var(--error);
    margin-right: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

.form-input:disabled,
.form-select:disabled {
    background: #f5f5f5;
    color: var(--text-light);
    cursor: not-allowed;
}

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

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

/* ========================================
 * 信息卡片网格（设置页用）
 * ======================================== */
.info-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.info-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.info-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.info-card.success::before { background: var(--success); }
.info-card.warning::before { background: var(--warning); }
.info-card.error::before { background: var(--error); }
.info-card.purple::before { background: #722ed1; }

.info-card-label {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-card-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.info-card-value code {
    font-size: 14px;
    padding: 2px 8px;
    background: #f0f5ff;
    border: 1px solid #adc6ff;
    border-radius: 4px;
    color: #1677ff;
    font-family: monospace;
}

.info-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-card-actions {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

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

.status-badge.success {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    color: #389e0d;
}

.status-badge.error {
    background: #fff1f0;
    border: 1px solid #ffa39e;
    color: #cf1322;
}

.status-badge.warning {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    color: #d48806;
}

.status-badge.info {
    background: #e6f4ff;
    border: 1px solid #91caff;
    color: #0958d9;
}

.status-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* 设置页分区标题 */
.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin: 24px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
}

@media (max-width: 992px) {
    .info-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .info-card-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
 * 数据表格
 * ======================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

/* 表格横向滚动（货币列多时需要拖拽滚动） */
.data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* 隐藏滚动条但保留滚动功能 */
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE/Edge */
    position: relative;
}
.data-table-wrapper::-webkit-scrollbar {
    display: none;                  /* Chrome/Safari */
}

/* 移动端滑动提示：桌面端默认隐藏 */
.mobile-scroll-tip {
    display: none;
}

/* 货币列区域可拖拽提示（仅货币列显示grab光标） */
.data-table-wrapper .col-currency {
    cursor: grab;
    transition: background 0.2s;
}

/* 货币列hover时高亮提示可拖拽 */
.data-table-wrapper .col-currency:hover {
    background: #f0f7ff;
}

.data-table tbody tr:hover .col-currency:hover {
    background: #d6ecff;
}

/* 拖拽时禁用文字选中 */
.data-table-wrapper.dragging .col-currency {
    cursor: grabbing !important;
    user-select: none;
    -webkit-user-select: none;
}

.data-table {
    min-width: max-content;
}

/* ---------- sticky 固定列 ---------- */
.data-table .sticky-col {
    position: sticky;
    z-index: 2;
}

/* 表头 sticky 列层级更高 */
.data-table thead .sticky-col {
    z-index: 3;
}

/* 左侧固定列：累积偏移 */
.data-table .sticky-left-0 { left: 0; }
.data-table .sticky-left-1 { left: 40px; }
.data-table .sticky-left-2 { left: 100px; }
.data-table .sticky-left-3 { left: 180px; }
.data-table .sticky-left-4 { left: 300px; }

/* 右侧固定列：累积偏移 */
.data-table .sticky-right-0 { right: 0; }
.data-table .sticky-right-1 { right: 160px; }

/* 固定列背景色（不透明，防止滚动时内容透过来） */
.data-table thead .sticky-col {
    background: #fafafa;
}

.data-table tbody tr .sticky-col {
    background: #fff;
}

/* 斑马行固定列背景 */
.data-table tbody tr:nth-child(even) .sticky-col {
    background: #fafafa;
}

/* hover行固定列背景 */
.data-table tbody tr:hover .sticky-col {
    background: #e6f4ff;
}

.data-table th {
    padding: 8px 16px;
    height: 32px;
    box-sizing: border-box;
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 8px 16px;
    height: 32px;
    box-sizing: border-box;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* 斑马纹 */
.data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

/* hover效果 */
.data-table tbody tr:hover {
    background: #e6f4ff;
}

.data-table .table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.data-table .table-actions .btn-sm {
    padding: 2px 5px;
    line-height: 1;
}
.data-table .table-actions .btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ---------- 行悬浮操作按钮 ---------- */
.data-table tbody tr {
    position: relative;
}

.row-actions {
    display: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    gap: 6px;
    align-items: center;
    background: #e6f4ff;
    padding: 3px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.data-table tbody tr:hover .row-actions {
    display: flex;
}

.row-actions .btn-sm {
    padding: 2px 5px;
    line-height: 1;
}

.row-actions .btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ========================================
 * 标签
 * ======================================== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 20px;
    border-radius: 4px;
    background: #f0f0f0;
    color: var(--text-secondary);
    white-space: nowrap;
}

.tag-success {
    background: #f6ffed;
    color: var(--success);
    border: 1px solid #b7eb8f;
}

.tag-error {
    background: #fff2f0;
    color: var(--error);
    border: 1px solid #ffccc7;
}

.tag-warning {
    background: #fffbe6;
    color: var(--warning);
    border: 1px solid #ffe58f;
}

.tag-primary {
    background: #e6f4ff;
    color: var(--primary);
    border: 1px solid #91caff;
}

/* ========================================
 * 分页
 * ======================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.2s;
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .disabled {
    color: var(--text-light);
    cursor: not-allowed;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
    margin-right: 12px;
}

/* ========================================
 * 模态框
 * ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

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

/* ========================================
 * 确认框
 * ======================================== */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1100;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.show {
    display: flex;
}

.confirm-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

.confirm-title {
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.confirm-content {
    padding: 16px 24px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

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

/* ========================================
 * Toast 提示
 * ======================================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: 4px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    color: var(--text-main);
    min-width: 200px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

/* ========================================
 * 开关
 * ======================================== */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 22px;
    transition: background 0.2s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch input:checked + .switch-slider {
    background: var(--primary);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
}

/* ========================================
 * 搜索框
 * ======================================== */
.search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-light);
    pointer-events: none;
}

.search-box .form-input {
    padding-left: 32px;
    width: 220px;
}

/* ========================================
 * 排序链接
 * ======================================== */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    font-weight: inherit;
    text-decoration: none;
    cursor: pointer;
}

.sort-link:hover {
    color: var(--primary);
}

.sort-link.active {
    color: var(--primary);
}

.sort-link::after {
    content: '⇅';
    font-size: 12px;
    opacity: 0.5;
}

.sort-link.asc::after {
    content: '↑';
    opacity: 1;
}

.sort-link.desc::after {
    content: '↓';
    opacity: 1;
}

/* ========================================
 * 空数据
 * ======================================== */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: #d9d9d9;
}

.empty-text {
    font-size: 14px;
}

/* ========================================
 * 通用辅助类
 * ======================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-secondary { color: var(--text-secondary); }
.text-light { color: var(--text-light); }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

/* ========================================
 * daterangepicker 样式适配
 * ======================================== */
.daterangepicker {
    z-index: 1050;
    font-family: inherit;
    box-shadow: var(--shadow-lg);
}

.daterangepicker .calendar-table {
    border-radius: 4px;
}

.daterangepicker td.active,
.daterangepicker td.active:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.daterangepicker td.in-range {
    background: #e6f4ff;
    color: var(--text-main);
}

.daterangepicker .ranges li:hover {
    background: var(--primary);
}

.daterangepicker .ranges li.active {
    background: var(--primary);
}

.daterangepicker .drp-buttons .applyBtn {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.daterangepicker .drp-buttons .cancelBtn {
    background: #fff;
    border-color: var(--border);
    color: var(--text-main);
}

/* ========================================
 * 响应式设计 - 移动端适配
 * ======================================== */
@media (max-width: 768px) {
    /* 侧边栏移出屏幕外 */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* 主内容区全宽 */
    .main-content {
        margin-left: 0;
    }

    /* 显示菜单切换按钮 */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 顶部栏调整 */
    .top-header {
        padding: 0 12px;
    }

    .page-title {
        font-size: 16px;
    }

    .header-right {
        gap: 8px;
    }

    .user-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .logout-link span {
        display: none;
    }

    /* 内容区减小内边距 */
    .content {
        padding: 12px;
    }

    /* 工具栏纵向排列 */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        justify-content: flex-start;
    }

    /* 移动端：彻底放开外层裁剪，确保 .data-table-wrapper 的滚动区域不会被切掉 */
    .content,
    .card {
        overflow-x: visible !important;
        max-width: none !important;
        width: auto !important;
    }

    /* 表格横向滚动 + 触摸滑动 */
    .data-table-wrapper {
        width: 100%;
        overflow-x: scroll !important;
        -webkit-overflow-scrolling: touch;
        touch-action: auto;
    }

    .data-table {
        /* 移动端：强制表格按内容实际宽度撑开，兼容所有浏览器 */
        display: table !important;
        table-layout: auto !important;
        width: max-content !important;
        min-width: 100% !important;
        max-width: none !important;
    }

    /* 移动端单元格不换行，保证IP和更新时间列不被挤压 */
    .data-table th,
    .data-table td {
        white-space: nowrap !important;
        display: table-cell !important;
        max-width: none !important;
        box-sizing: border-box;
    }

    /* 移动端禁用sticky固定列，所有列可自由滚动 */
    .data-table .sticky-col,
    .data-table thead .sticky-col,
    .data-table tbody tr .sticky-col,
    .data-table tbody tr:nth-child(even) .sticky-col,
    .data-table tbody tr:hover .sticky-col {
        position: static !important;
        left: auto !important;
        right: auto !important;
        z-index: auto !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    /* 彻底清除 sticky-right 系列的固定偏移，避免其影响 max-content 宽度计算 */
    .data-table .sticky-right-0,
    .data-table .sticky-right-1,
    .data-table .sticky-left-0,
    .data-table .sticky-left-1,
    .data-table .sticky-left-2,
    .data-table .sticky-left-3,
    .data-table .sticky-left-4,
    .data-table .sticky-left-5 {
        right: auto !important;
        left: auto !important;
    }

    /* 移动端显示滑动提示 */
    .mobile-scroll-tip {
        display: block;
        text-align: center;
        padding: 8px 12px;
        color: #666;
        font-size: 12px;
        background: #fafafa;
        border-bottom: 1px solid #e8e8e8;
    }

    /* 卡片减小内边距 */
    .card-body {
        padding: 16px;
    }

    .card-header {
        padding: 12px 16px;
    }

    /* 搜索框全宽 */
    .search-box .form-input {
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    /* 表单行纵向排列 */
    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        min-width: 100%;
    }

    /* 筛选栏在小屏下纵向排列 */
    .filter-bar form {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar .form-row .form-group {
        width: 100%;
    }
    .filter-bar .form-row .form-input,
    .filter-bar .form-row .form-select {
        width: 100%;
    }
    .filter-bar .flex {
        width: 100%;
    }

    /* 模态框全宽 */
    .modal {
        width: 95%;
        max-height: 85vh;
    }

    /* 移动端列显示弹出窗口：fixed 居中显示，避免被挤出屏幕或被横向滚动区域遮挡 */
    .column-dropdown {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        margin-top: 0 !important;
        transform: translate(-50%, -50%);
        width: 260px;
        max-width: 90vw;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 10000;
    }

    /* 弹出时背景遮罩（通过 ::before 实现半透明遮罩，点击外部仍可关闭） */
    .column-control:has(.column-dropdown.show)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 9999;
    }

    /* 分页简化 */
    .pagination a,
    .pagination span {
        min-width: 28px;
        height: 28px;
        font-size: 13px;
    }
}

/* 设备信息列（兼容历史列名） */
.col-device_info {
    width: 120px;
}

/* 设备信息悬停提示 */
.device-info {
    cursor: help;
    color: #666;
    font-size: 13px;
}

/* ---------- 新：IP地址列（设备图标+IP文本）---------- */
.col-device_ip {
    width: 180px;
    min-width: 160px;
}

.device-ip-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: help;
    max-width: 100%;
    vertical-align: middle;
}

.device-ip-cell .device-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    transition: filter 0.2s ease;
    -webkit-user-drag: none;
    user-select: none;
}

/* 在线：保持原色（您PNG是黑色的，保持即可） */
.device-ip-cell .device-icon-online {
    filter: none;
    -webkit-filter: none;
}

/* 离线：变灰 + 降低透明度 */
.device-ip-cell .device-icon-offline {
    filter: grayscale(100%) opacity(0.5);
    -webkit-filter: grayscale(100%) opacity(0.5);
}

.device-ip-cell .ip-text {
    display: inline-block;
    vertical-align: middle;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

/* JS tooltip - position:fixed 突破 overflow:hidden 限制 */
.js-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    white-space: pre;
    line-height: 1.6;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: opacity 0.15s;
}

@media (max-width: 480px) {
    .content {
        padding: 8px;
    }

    .top-header {
        padding: 0 8px;
    }

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