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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.5;
    font-size: 14px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* 头部 */
.header {
    background: #1a1a2e;
    color: #fff;
    padding: 16px 24px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 18px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: #1890ff; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-success { background: #52c41a; color: #fff; }
.btn-warning { background: #faad14; color: #333; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-info { background: #13c2c2; color: #fff; }

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

/* 表单 */
input, select {
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: #1890ff;
}

input[type="number"] { width: 80px; }
input[type="text"] { width: 180px; }

label {
    font-size: 13px;
    color: #666;
    margin-right: 6px;
}

/* 区块 */
.search-config-section,
.operation-section,
.selection-section,
.logs-section,
.pagination-section,
.clicker-section {
    background: #fff;
    padding: 14px 20px;
    border-radius: 6px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* 连点控制区 */
.clicker-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 16px;
    flex-wrap: wrap;
}

.clicker-rate-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.clicker-rate-group label {
    font-weight: 500;
    color: #333;
}

.clicker-rate-group select {
    min-width: 160px;
}

.clicker-buttons {
    display: flex;
    gap: 8px;
}

.search-box, .config-box,
.operation-buttons, .time-config,
.selection-buttons, .data-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.selected-count {
    font-size: 13px;
    color: #666;
    margin-left: 8px;
}

/* 表格 */
.table-section {
    background: #fff;
    border-radius: 6px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    overflow-x: auto;
}

.device-table, .data-table, .logs-table {
    width: 100%;
    border-collapse: collapse;
}

.device-table th, .device-table td,
.data-table th, .data-table td,
.logs-table th, .logs-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.device-table th, .data-table th, .logs-table th {
    background: #fafafa;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.device-table tbody tr:hover,
.data-table tbody tr:hover {
    background: #fafafa;
}

.device-table tbody tr.selected {
    background: #e6f7ff;
}

.checkbox-col {
    width: 40px;
    text-align: center;
}

/* 状态标签 */
.status-badge, .status-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.status-idle, .status-disabled { background: #f5f5f5; color: #8c8c8c; }
.status-logging, .status-running { background: #fff7e6; color: #d48806; }
.status-in_room { background: #e6f7ff; color: #1890ff; }  /* 游戏局内 - 蓝色 */
.status-success, .status-active { background: #f6ffed; color: #389e0d; }
.status-failed { background: #fff2f0; color: #cf1322; }
.status-expired { background: #fff1f0; color: #a8071a; }

/* 加载和空状态 */
.loading, .empty-message, .empty-msg {
    text-align: center;
    padding: 32px;
    color: #999;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

#pageInfo, .pagination span {
    font-size: 13px;
    color: #666;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 6px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
}

.modal-large { max-width: 900px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 { font-size: 16px; font-weight: 500; }

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.modal-body { 
    padding: 20px; 
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal-body textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-family: monospace;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 4px;
    z-index: 1001;
    font-size: 13px;
    background: #333;
    color: #fff;
}

.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.warning { background: #faad14; color: #333; }

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    font-family: monospace;
}

.form-tip {
    background: #f6f8fa;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}

.form-tip p {
    margin: 0;
}

/* 单选按钮组 */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    transition: all 0.2s;
}

.radio-label:hover {
    border-color: #1890ff;
    background: #f6f8fa;
}

.radio-label input[type="radio"] {
    margin: 0;
}

.radio-label span {
    font-weight: 500;
    color: #333;
}

.radio-label small {
    color: #999;
    font-size: 12px;
}

.radio-label input[type="radio"]:checked + span {
    color: #1890ff;
}

/* 按钮选择组 */
.btn-group-select {
    display: flex;
    gap: 0;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #d9d9d9;
}

.btn-select {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: #fff;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid #d9d9d9;
}

.btn-select:last-child {
    border-right: none;
}

.btn-select:hover {
    background: #f5f5f5;
}

.btn-select.active {
    background: #1890ff;
    color: #fff;
}

/* 设备选择列表 */
.device-select-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.device-select-toolbar #deviceSelectCount {
    font-size: 13px;
    color: #666;
}

.device-select-list {
    height: 160px;
    overflow-y: auto;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
}

.device-select-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.device-select-item:last-child {
    border-bottom: none;
}

.device-select-item:hover {
    background: #f6f8fa;
}

.device-select-item.selected {
    background: #e6f7ff;
    border-color: #91d5ff;
}

.device-select-item .device-number {
    width: 50px;
    font-weight: 600;
    color: #1890ff;
}

.device-select-item .device-id {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
    color: #333;
}

.device-select-item .device-account {
    font-size: 12px;
    color: #999;
    margin-left: 8px;
}

.device-select-item .select-order {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1890ff;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}

.device-select-item:not(.selected) .select-order {
    display: none;
}

.device-select-list .loading-text,
.device-select-list .empty-text {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* 日志区 */
.logs-section { flex-direction: column; align-items: stretch; }
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logs-header h3 { font-size: 15px; font-weight: 500; }

.logs-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.logs-table-container {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
}

.logs-table th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.logs-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== 管理后台样式 ========== */
.admin-login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    background: #fff;
    padding: 32px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 360px;
}

.login-card h2 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 24px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
}

.error-msg {
    color: #ff4d4f;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}

/* 标签页 */
.tab-nav {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s;
}

.tab-btn:hover { background: #f5f5f5; }
.tab-btn.active {
    background: #1890ff;
    color: #fff;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* 面板区块 */
.panel-section {
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.panel-section h3 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 16px;
    color: #333;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 { margin-bottom: 0; }

.filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.form-row .form-group {
    margin-bottom: 0;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
}

.cardkey-code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
    margin-right: 6px;
}

.log-detail {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: #fff;
    padding: 24px;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: #1890ff;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #666;
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }
    
    .header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .header h1 {
        font-size: 16px;
    }

    .search-config-section,
    .operation-section,
    .selection-section,
    .clicker-section {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .search-box, .config-box,
    .operation-buttons, .time-config,
    .selection-buttons, .data-buttons {
        justify-content: center;
        width: 100%;
    }
    
    .operation-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .data-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .clicker-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .clicker-rate-group {
        width: 100%;
        justify-content: center;
    }
    
    .clicker-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .clicker-buttons .btn {
        padding: 10px 8px;
    }

    input[type="text"] { width: 100%; }

    .form-row { flex-direction: column; }
    .form-row .form-group { width: 100%; }
    .form-row input { width: 100%; }
    
    /* 移动端表格改为卡片式布局 */
    .table-section {
        background: transparent;
        box-shadow: none;
    }
    
    .device-table {
        display: block;
    }
    
    .device-table thead {
        display: none;
    }
    
    .device-table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .device-table tbody tr {
        display: block;
        background: #fff;
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        position: relative;
    }
    
    .device-table tbody tr.selected {
        background: #e6f7ff;
        border: 1px solid #1890ff;
    }
    
    .device-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .device-table tbody td:last-child {
        border-bottom: none;
    }
    
    .device-table tbody td::before {
        content: attr(data-label);
        font-weight: 500;
        color: #666;
        font-size: 12px;
        flex-shrink: 0;
        margin-right: 12px;
    }
    
    .device-table tbody td.checkbox-col {
        position: absolute;
        top: 12px;
        right: 12px;
        padding: 0;
        border: none;
    }
    
    .device-table tbody td.checkbox-col::before {
        display: none;
    }
    
    .device-table tbody td.checkbox-col input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    /* 设备ID截断显示 */
    .device-table tbody td[data-label="设备ID"] {
        font-family: monospace;
        font-size: 11px;
        word-break: break-all;
    }
    
    /* 状态标签在移动端更紧凑 */
    .status-badge {
        padding: 2px 6px;
        font-size: 11px;
    }
    
    /* 操作按钮在移动端 */
    .device-table tbody td.action-col {
        justify-content: flex-end;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px dashed #e8e8e8;
        border-bottom: none;
    }
    
    .device-table tbody td.action-col::before {
        display: none;
    }
    
    .device-table tbody td.action-col .btn {
        flex: 1;
    }
    
    /* 分页优化 */
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .pagination .btn {
        padding: 8px 12px;
    }
    
    /* 弹窗优化 */
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 12px 16px;
    }
    
    /* 日志表格卡片化 */
    .logs-table {
        display: block;
    }
    
    .logs-table thead {
        display: none;
    }
    
    .logs-table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .logs-table tbody tr {
        display: block;
        background: #fff;
        border-radius: 6px;
        padding: 10px;
        border: 1px solid #f0f0f0;
    }
    
    .logs-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        font-size: 12px;
    }
    
    .logs-table tbody td::before {
        content: attr(data-label);
        font-weight: 500;
        color: #999;
        margin-right: 8px;
    }
}


/* 提取数据选项区 */
.extract-options {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 4px;
}

.extract-options .checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
}

.extract-options .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.extract-options .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* 日志状态颜色 */
.log-status-success { color: #52c41a; font-weight: 500; }
.log-status-failed { color: #ff4d4f; font-weight: 500; }

/* 详细统计信息样式 */
.detailed-stats {
    margin-top: 24px;
}

.stats-section {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stats-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

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

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    padding: 12px 16px;
    background: #f9f9f9;
    border-radius: 6px;
}

.stat-item .stat-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.stat-item .stat-value {
    font-size: 20px;
    font-weight: 600;
    color: #1890ff;
    margin: 0;
}

.stat-item .stat-value.success {
    color: #52c41a;
}

.stat-item .stat-value.error {
    color: #ff4d4f;
}

/* 操作类型分布 */
.operation-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.op-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 13px;
}

.op-stat-item .op-type {
    color: #666;
}

.op-stat-item .op-count {
    font-weight: 600;
    color: #1890ff;
    background: #e6f7ff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* 日志详情列宽度优化 */
.log-detail {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .stats-row {
        flex-direction: column;
    }
    
    .stat-item {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .operation-stats {
        flex-direction: column;
    }
    
    .op-stat-item {
        justify-content: space-between;
    }
}

/* 颜色选择器样式 */
.color-picker-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.color-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.color-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.color-btn.selected {
    box-shadow: 0 0 0 3px #1890ff;
    transform: scale(1.1);
}

.color-btn-clear {
    background: #f0f0f0;
    color: #999;
    font-size: 14px;
    border: 1px dashed #ccc;
}

.color-btn-clear:hover {
    background: #e0e0e0;
    color: #666;
}

/* 名称预览 */
.nickname-preview {
    margin-top: 8px;
    padding: 8px 12px;
    background: #1a1a2e;
    border-radius: 4px;
    font-size: 14px;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.nickname-preview:empty::before {
    content: '预览效果';
    color: #666;
}
