/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0b1a2f;
    color: #e0e0e0;
    padding: 20px;
}
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #0b1a2f;
}
::-webkit-scrollbar-thumb {
    background: #2a3f55;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4fc3f7;
}
* {
    scrollbar-color: #2a3f55 #0b1a2f;
    scrollbar-width: thin;
}

.container { max-width: 1200px; margin: 0 auto; }

/* ===== 顶部 header ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #1a2f45;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
header h1 {
    font-size: 24px;
    color: #4fc3f7;
}
.user-info {
    color: #aaa;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 4px;
    background: #1a2f45;
    padding-left:5px;

}
.user-info strong { color: #4fc3f7; }
.logout-btn {
    background: #ff5252;
    color: #fff;
    border: none;
    padding: 0px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    height:30px;
    margin-left: 8px;
}
.logout-btn:hover { background: #d32f2f; }

/* ===== 导航 tabs ===== */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #1a2f45;
}
.tab-link {
    background: none;
    border: none;
    color: #aaa;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: 0.2s;
    text-decoration: none;
    display: inline-block;
}
.tab-link:hover { color: #fff; }
.tab-link.active {
    color: #4fc3f7;
    border-bottom-color: #4fc3f7;
}

/* ===== 通用按钮 ===== */
.btn {
    background: #4fc3f7;
    color: #0b1a2f;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: background 0.2s;
}
.btn:hover { background: #38a8db; }
.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}
.btn-danger {
    background: #ff5252;
    color: #fff;
}
.btn-danger:hover { background: #d32f2f; }
.btn-warning {
    background: #ffa726;
    color: #0b1a2f;
}
.btn-warning:hover { background: #fb8c00; }
.btn-info {
    background: #29b6f6;
    color: #0b1a2f;
}
.btn-info:hover { background: #039be5; }
.btn-success {
    background: #4caf50;
    color: #fff;
}
.btn-success:hover { background: #388e3c; }
.btn-primary {
    background: #4fc3f7;
    color: #0b1a2f;
}
.btn-primary:hover { background: #38a8db; }

/* ===== 卡片 ===== */
.card {
    background: #1a2f45;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.card h3 {
    color: #4fc3f7;
    margin-bottom: 15px;
}

/* ===== 欢迎区域（admin.html） ===== */
.welcome-section {
    background: #1a2f45;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.welcome-section h2 {
    color: #4fc3f7;
    margin-bottom: 10px;
}
.welcome-section p {
    color: #b0bec5;
    line-height: 1.6;
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
    font-size: 14px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    border-radius: 4px;
    color: #fff;
}
.form-group input:focus,
.form-group select:focus {
    border-color: #4fc3f7;
    outline: none;
}
.form-group .checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.form-group .checkbox-group input[type="checkbox"] { width: auto; }

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
}
.pagination button {
    background: #1a2f45;
    color: #b0bec5;
    border: 1px solid #2a3f55;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
}
.pagination button:hover:not(:disabled) {
    background: #2a3f55;
    color: #fff;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination button.active {
    background: #4fc3f7;
    color: #0b1a2f;
    border-color: #4fc3f7;
    z-index: 1;
}
.pagination .info {
    color: #aaa;
    font-size: 13px;
    margin-right: 10px;
}
.page-numbers {
    display: inline-flex;
    gap: 0;
}
.page-numbers button {
    margin: 0;
    border-radius: 0;
}
.page-numbers button:first-child {
    border-radius: 4px 0 0 4px;
}
.page-numbers button:last-child {
    border-radius: 0 4px 4px 0;
}
.page-numbers button.active {
    background: #4fc3f7;
    color: #0b1a2f;
    border-color: #4fc3f7;
    z-index: 1;
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal.active { display: flex; }
.modal-content {
    background: #1a2f45;
    padding: 30px;
    border-radius: 8px;
    min-width: 350px;
    max-width: 500px;
}
.modal-content h3 {
    margin-bottom: 20px;
    color: #4fc3f7;
}
.modal-content .form-group { margin-bottom: 15px; }
.modal-content .form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #aaa;
}
.modal-content .form-group input,
.modal-content .form-group select {
    width: 100%;
    padding: 10px;
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    border-radius: 4px;
    color: #fff;
}
.modal-content .btn-group {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.modal-content .btn-group .btn { padding: 8px 20px; }

/* ===== 统计卡片（仪表盘） ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background: #1a2f45;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #4fc3f7;
}
.stat-card .label {
    color: #aaa;
    font-size: 14px;
}
.stat-card .value {
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    margin-top: 5px;
}

/* ===== 设备管理特有 ===== */
.top-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: stretch;
}
.stat-card-compact {
    background: #1a2f45;
    padding: 12px 20px;
    border-radius: 6px;
    border-left: 4px solid #4fc3f7;
    flex: 0 0 auto;
    min-width: 100px;
    cursor: pointer;
    transition: background 0.2s;
}
.stat-card-compact:hover { background: #2a3f55; }
.stat-card-compact .label { color: #aaa; font-size: 13px; }
.stat-card-compact .value { color: #fff; font-size: 24px; font-weight: bold; margin-top: 2px; }

.add-device-card {
    background: #1a2f45;
    padding: 12px 20px;
    border-radius: 6px;
    border-left: 4px solid #4fc3f7;
    flex: 1 1 0;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.add-device-card .label { color: #aaa; font-size: 13px; margin-bottom: 4px; }
.add-device-card .input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.add-device-card .input-row input {
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    flex: 1;
    min-width: 80px;
    max-width: none;
}
.add-device-card .input-row input:focus {
    border-color: #4fc3f7;
    outline: none;
}
.add-device-card .input-row .btn {
    flex-shrink: 0;
    margin-top: 0;
}

.real-time-box {
    background: #1a2f45;
    padding: 10px 18px;
    border-radius: 6px;
    flex: 1 1 0;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    border-left: 4px solid #4fc3f7;
}
.real-time-box .label { color: #aaa; font-size: 13px; margin-bottom: 4px; }
.real-time-box .data-preview {
    color: #4fc3f7;
    font-size: 14px;
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.real-time-box .status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}
.real-time-box .status-dot.online { background: #4caf50; }
.real-time-box .status-dot.offline { background: #666; }

.full-width-card {
    background: #1a2f45;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
.full-width-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 8px;
}
.full-width-card h3 {
    color: #4fc3f7;
    font-weight: 300;
    border-left: 3px solid #4fc3f7;
    padding-left: 12px;
    margin: 0;
}
.full-width-card .filter-select {
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    color: #e0e0e0;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    height: 30px;
    box-sizing: border-box;
}
.full-width-card .filter-select:focus { border-color: #4fc3f7; }
.full-width-card input[type="text"] {
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    max-width: 160px;
    height: 30px;
    box-sizing: border-box;
}
.full-width-card input[type="text"]:focus { border-color: #4fc3f7; }

.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #2a3f55;
}
th { color: #aaa; font-weight: normal; }
.status-badge {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
}
.status-online { background: #4caf50; color: #fff; }
.status-offline { background: #666; color: #fff; }

/* ===== 用户管理特有 ===== */
.user-add-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
    margin-bottom: 20px;
    background: #1a2f45;
    padding: 15px 20px;
    border-radius: 8px;
}
.user-add-row .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}
.user-add-row .field label { color: #aaa; font-size: 13px; }
.user-add-row .field input,
.user-add-row .field select {
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}
.user-add-row .field input:focus,
.user-add-row .field select:focus { border-color: #4fc3f7; }
.user-add-row .btn { padding: 8px 20px; white-space: nowrap; margin-bottom: 0; }
.user-add-row .result { color: #aaa; font-size: 14px; margin-left: 10px; }

.max-devices-input {
    width: 60px;
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    color: #fff;
    padding: 4px;
    border-radius: 4px;
}
.max-devices-input:focus {
    border-color: #4fc3f7;
    outline: none;
}

/* ===== 模板预览弹窗 ===== */
.preview-modal {
    min-width: 560px;
    max-width: 820px;
    width: 90%;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
}
.preview-modal h3 {
    margin-top: 0;
    flex-shrink: 0;
}
.preview-modal #previewModalBody {
    flex: 1 1 auto;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 4px;
}
.preview-modal .btn-group {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
.preview-label {
    color: #4fc3f7;
    font-size: 13px;
    font-weight: bold;
    margin: 12px 0 6px;
    border-left: 3px solid #4fc3f7;
    padding-left: 8px;
}
.preview-content {
    background: #0b1a2f;
    border: 1px solid #2a3f55;
    color: #e0e0e0;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Consolas', 'Courier New', monospace;
}
.preview-success {
    color: #4caf50;
    font-size: 13px;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(76,175,80,0.08);
    border: 1px solid rgba(76,175,80,0.3);
    border-radius: 4px;
}
.preview-fail {
    color: #ff5252;
    font-size: 13px;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255,82,82,0.08);
    border: 1px solid rgba(255,82,82,0.3);
    border-radius: 4px;
}

/* Markdown 真实渲染区域（模拟企业微信 / PushPlus 显示效果） */
.md-preview {
    background: #ffffff;
    color: #1f2937;
    padding: 14px 16px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.7;
    overflow: auto;
    max-height: 420px;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 {
    color: #111827;
    margin: 14px 0 8px;
    line-height: 1.35;
}
.md-preview h1 { font-size: 20px; font-weight: 700; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }
.md-preview h2 { font-size: 17px; font-weight: 700; }
.md-preview h3 { font-size: 15px; font-weight: 600; }
.md-preview p { margin: 6px 0; }
.md-preview blockquote {
    margin: 8px 0;
    padding: 6px 12px;
    border-left: 4px solid #9ca3af;
    background: #f3f4f6;
    color: #374151;
}
.md-preview code {
    font-family: 'Consolas', 'SFMono-Regular', Menlo, monospace;
    background: #f3f4f6;
    color: #dc2626;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
}
.md-preview pre {
    background: #111827;
    color: #e5e7eb;
    padding: 10px 12px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12.5px;
    line-height: 1.55;
}
.md-preview pre code {
    background: transparent;
    color: #e5e7eb;
    padding: 0;
    font-size: 12.5px;
}
.md-preview a {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid rgba(37,99,235,0.3);
}
.md-preview hr {
    border: none;
    border-top: 1px solid #d1d5db;
    margin: 12px 0;
}
.md-preview ul, .md-preview ol {
    padding-left: 24px;
    margin: 6px 0;
}
.md-preview strong { color: #111827; font-weight: 700; }
.md-preview .wx-warn { color: #d97706; font-weight: 600; }
.md-preview .wx-ok   { color: #059669; font-weight: 600; }
.md-preview .wx-err  { color: #dc2626; font-weight: 600; }
.md-preview .wx-info { color: #2563eb; font-weight: 600; }
.md-preview .wx-muted { color: #6b7280; }
.md-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}
.md-preview table th, .md-preview table td {
    border: 1px solid #d1d5db;
    padding: 6px 10px;
    text-align: left;
}
.md-preview table th {
    background: #f3f4f6;
    font-weight: 600;
    color: #111827;
}

/* Text 纯文本预览（模拟企业微信 text 消息气泡） */
.txt-preview {
    background: #ffffff;
    color: #111827;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 14.5px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* 帮助文本 */
.help-text {
    color: #78909c;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.6;
}

/* ===== 响应式 ===== */
@media (max-width: 800px) {
    .top-row { flex-direction: column; }
    .add-device-card, .real-time-box { width: 100%; flex: none; }
    .user-add-row { flex-direction: column; align-items: stretch; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
}
/* ===== 统一按钮间距（修复 device.html 操作列按钮粘连） ===== */
.btn-sm {
    margin-right: 8px;
}
.btn-sm:last-child {
    margin-right: 0;
}