* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "Microsoft YaHei", sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 8px; width: 360px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.login-box h2 { text-align: center; margin-bottom: 30px; color: #333; }
.form-group { margin-bottom: 16px; }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: #667eea; }
.msg { margin-top: 12px; text-align: center; font-size: 13px; }
.msg.error { color: #e74c3c; }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; transition: opacity 0.2s; }
.btn:hover { opacity: 0.85; }
.btn-primary { background: #667eea; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }
.btn-group { display: flex; gap: 4px; flex-wrap: wrap; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: #1a1a2e; color: #fff; display: flex; flex-direction: column; position: fixed; height: 100vh; }
.logo { padding: 20px; font-size: 16px; font-weight: bold; text-align: center; border-bottom: 1px solid #333; }
/* nav-menu 必须能滚动 — 菜单项多于一屏（业务/定位/运维/通讯/日志/系统六大块）时
   会被 .sidebar 的 100vh 裁掉，必须加 overflow-y:auto + min-height:0 让 flex:1
   生效产生滚动 */
.nav-menu { list-style: none; flex: 1 1 auto; min-height: 0; padding-top: 10px; overflow-y: auto; overscroll-behavior: contain; }
.nav-item { padding: 12px 20px; cursor: pointer; transition: background 0.2s; }
.nav-item:hover { background: #16213e; }
.nav-item.active { background: #667eea; }
/* 深色 sidebar 配深色细滚动条（webkit 内核） */
.nav-menu::-webkit-scrollbar { width: 6px; }
.nav-menu::-webkit-scrollbar-track { background: transparent; }
.nav-menu::-webkit-scrollbar-thumb { background: #2d3a5a; border-radius: 3px; }
.nav-menu::-webkit-scrollbar-thumb:hover { background: #3d4a6a; }
/* Firefox */
.nav-menu { scrollbar-width: thin; scrollbar-color: #2d3a5a transparent; }
.nav-footer { padding: 15px; text-align: center; border-top: 1px solid #333; flex-shrink: 0; }
.nav-footer .btn { background: #444; color: #ccc; }
.content { flex: 1; margin-left: 200px; padding: 24px; }
.page { display: none; }
.page.active { display: block; }
.page h3 { margin-bottom: 16px; font-size: 18px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); text-align: center; }
.stat-card .num { font-size: 28px; font-weight: bold; color: #667eea; }
.stat-card .label { font-size: 13px; color: #888; margin-top: 4px; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.search-input { padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; width: 240px; }
.search-input:focus { outline: none; border-color: #667eea; }
select { padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.data-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 600; font-size: 12px; color: #666; white-space: nowrap; }
.data-table td { padding: 10px 12px; border-top: 1px solid #eee; font-size: 13px; }
.data-table tr:hover { background: #f5f7ff; }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-red { background: #fce4ec; color: #c62828; }
.badge-gray { background: #f5f5f5; color: #757575; }
.badge-orange { background: #fff3e0; color: #e65100; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.pagination button { padding: 4px 10px; border: 1px solid #ddd; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; }
.pagination button.active { background: #667eea; color: #fff; border-color: #667eea; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 8px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #eee; }
.modal-header h4 { font-size: 15px; }
.modal-close { font-size: 22px; cursor: pointer; color: #999; }
.modal-body { padding: 20px; }
.modal-body .form-row { margin-bottom: 12px; }
.modal-body .form-row label { display: block; margin-bottom: 4px; font-size: 13px; color: #666; }
.modal-body .form-row input, .modal-body .form-row select, .modal-body .form-row textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px;
}
.modal-body .form-row textarea { height: 80px; resize: vertical; }
.modal-body .form-row input:focus, .modal-body .form-row select:focus { outline: none; border-color: #667eea; }
.modal-body .btn { margin-top: 8px; }
.card-codes-box { background: #f8f9fa; padding: 12px; border-radius: 4px; max-height: 300px; overflow-y: auto; font-family: monospace; font-size: 13px; line-height: 1.8; word-break: break-all; user-select: all; }

/* Modal wide */
.modal-wide { width: 900px; max-width: 95vw; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 960px; }
.settings-card { background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.settings-card h4 { font-size: 15px; color: #333; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #667eea; display: flex; align-items: center; gap: 8px; }
.settings-card h4 .icon { width: 28px; height: 28px; background: #667eea; color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; color: #555; font-weight: 500; }
.form-row input, .form-row textarea, .form-row select {
    width: 100%; padding: 10px 12px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 13px;
    box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; background: #fafbfc;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.1); background: #fff;
}
.form-row input:disabled { background: #f5f5f5; color: #999; cursor: not-allowed; }
.form-row textarea { height: 100px; resize: vertical; }
/* color picker 用原生控件，避免被 width:100%/padding:10px 12px 拉成一条线 */
.form-row input[type="color"] { width: 44px; height: 36px; padding: 2px; }
.form-row .hint { font-size: 11px; color: #999; margin-top: 4px; }
.settings-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid #f0f0f0; }
.msg-success { color: #27ae60; font-size: 13px; margin-top: 8px; }
.msg-error { color: #e74c3c; font-size: 13px; margin-top: 8px; }
.upload-area { margin-top: 6px; }
.upload-area input[type="file"] { font-size: 13px; padding: 8px; background: #fafbfc; border: 1px dashed #ddd; border-radius: 6px; width: 100%; cursor: pointer; }
.upload-area input[type="file"]:hover { border-color: #667eea; background: #f5f7ff; }
.upload-status { margin-top: 6px; font-size: 12px; color: #667eea; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 8px 0; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: #667eea; cursor: pointer; }

/* Checkbox label */
.checkbox-label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.checkbox-label input { width: auto; }

/* Device detail */
.device-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.device-info-card { background: #f8f9fa; padding: 16px; border-radius: 8px; }
.device-info-card h5 { font-size: 13px; color: #666; margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 6px; }
.device-info-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.device-info-row .label { color: #888; }
.device-info-row .value { font-weight: 500; }
.device-log-box { max-height: 400px; overflow-y: auto; }
.device-log-entry { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; font-size: 12px; display: flex; gap: 12px; }
.device-log-entry .log-time { color: #999; white-space: nowrap; min-width: 140px; }
.device-log-entry .log-type { font-weight: 600; min-width: 100px; }
.device-log-entry .log-msg { flex: 1; word-break: break-all; }
.log-type-mock_start { color: #27ae60; }
.log-type-mock_stop { color: #e74c3c; }
.log-type-heartbeat { color: #3498db; }
.log-type-app_foreground { color: #8e44ad; }
.log-type-error { color: #e74c3c; font-weight: bold; }
.log-type-unicom_launch { color: #f39c12; }

/* Status dot */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.status-dot.online { background: #27ae60; }
.status-dot.offline { background: #ccc; }
.status-dot.mocking { background: #667eea; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── 新增样式 ─── */

/* 菜单分组标题 */
.nav-section { padding: 14px 20px 4px; font-size: 11px; color: #6b7191; letter-spacing: 1px; user-select: none; pointer-events: none; }

/* 多状态 stat-card */
.stat-card.warning .num { color: #f39c12; }
.stat-card.danger .num { color: #e74c3c; }

/* Dashboard 拓展 */
.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.dash-card { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.dash-card h4 { font-size: 14px; color: #333; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid #667eea; }
.empty { padding: 20px; text-align: center; color: #999; font-size: 13px; }

/* Alert row in dashboard */
.alert-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.alert-row:last-child { border-bottom: none; }
.alert-type { flex: 1; font-family: monospace; color: #555; }
.alert-sev { padding: 2px 8px; border-radius: 8px; font-size: 11px; }
.alert-sev.sev-info { background: #e3f2fd; color: #1565c0; }
.alert-sev.sev-warn { background: #fff3e0; color: #e65100; }
.alert-sev.sev-critical { background: #fce4ec; color: #c62828; }
.alert-count { font-weight: 600; min-width: 32px; text-align: right; }

/* 区域芯片 */
.region-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.region-chip { padding: 6px 12px; background: #fff; border: 1px solid #e0e6ef; border-radius: 16px; font-size: 12px; cursor: pointer; transition: all 0.2s; }
.region-chip:hover { background: #667eea; color: #fff; border-color: #667eea; }
.region-chip b { color: #667eea; margin-left: 4px; }
.region-chip:hover b { color: #fff; }

/* 分组颜色块 */
.color-chip { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; margin-right: 4px; border: 1px solid rgba(0,0,0,0.08); }

/* 蓝色 badge */
.badge-blue { background: #e3f2fd; color: #1565c0; }

/* 等宽字体 cell */
.mono, td.mono { font-family: ui-monospace, "Cascadia Code", "Consolas", monospace; font-size: 12px; }

/* 导出页 */
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; max-width: 960px; }
.export-card { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.export-card h4 { font-size: 14px; margin-bottom: 8px; color: #333; }
.export-card p.hint { font-size: 12px; color: #888; margin-bottom: 14px; line-height: 1.6; }

/* 定位任务的 mode-section / 命令的 args-section */
.task-mode-section, .cmd-args-section { background: #f8f9fa; padding: 12px; border-radius: 6px; margin: 8px 0; }
.task-mode-section .form-row, .cmd-args-section .form-row { margin-bottom: 8px; }

/* 更多日志类型颜色 */
.log-type-coord_change { color: #3498db; }
.log-type-cmd_ack { color: #16a085; }
.log-type-heartbeat_anomaly { color: #c0392b; }
.log-type-tamper_alert { color: #c0392b; font-weight: bold; }
.log-type-login_failure { color: #e74c3c; }
.log-type-auth_expired { color: #f39c12; }
.log-type-info { color: #95a5a6; }

/* 公告 / 命令 / 告警 表格 cell 限宽 */
.data-table td code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: #555; }

/* 修复 .modal-body input 在 multiple select 下高度问题 */
.modal-body .form-row select[multiple] { height: auto; min-height: 80px; }

/* spinner（备份/还原等待时用） */
.spinner { width: 40px; height: 40px; border: 4px solid #e0e6ef; border-top-color: #667eea; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
