/* 应急跌落事件监控系统 - Web前端样式 */
[v-cloak] { display: none; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
}

/* ---------- 顶部控制区 ---------- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    flex-wrap: wrap;
    gap: 8px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar .title { font-size: 17px; font-weight: bold; color: #1a3c6e; margin-right: 16px; }
.topbar label { color: #666; }
.topbar select {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 160px;
    background: #fff;
}
.status { font-weight: bold; }
.status.ok { color: #2e9e44; }
.status.bad { color: #cc3333; }
.status.idle { color: #999; }
.mqtt-status { color: #888; font-size: 12px; max-width: 420px; }

/* ---------- 按钮 ---------- */
.btn {
    padding: 5px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
.btn:hover:not(:disabled) { background: #f0f0f0; }
.btn.primary { background: #1a73c6; border-color: #1a73c6; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #155da1; }
.btn.danger { background: #c64444; border-color: #c64444; color: #fff; }
.btn.danger:hover { background: #a83636; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
a.btn { text-decoration: none; color: inherit; }

/* ---------- 标签页 ---------- */
.tabs {
    display: flex;
    gap: 2px;
    background: #fff;
    padding: 0 12px;
    border-bottom: 1px solid #e0e0e0;
}
.tabs button {
    padding: 9px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-bottom: 2px solid transparent;
}
.tabs button.active {
    color: #1a73c6;
    font-weight: bold;
    border-bottom-color: #1a73c6;
}
.tabs button:hover { color: #1a73c6; }

/* ---------- 内容区 ---------- */
.content { padding: 12px 16px; height: calc(100vh - 108px); }
.tab-panel { height: 100%; display: flex; flex-direction: column; gap: 10px; }

.table-info { color: #888; display: flex; justify-content: space-between; }

.table-wrap {
    flex: 1;
    overflow: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
    position: sticky;
    top: 0;
    background: #f5f7fa;
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
    text-align: left;
    color: #445;
}
tbody td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    font-family: Consolas, "Courier New", monospace;
}
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #eef4fb; }
tr.row-poweron td { color: #b8860b; font-weight: bold; }
tr.row-timeout td { color: #cc3333; font-weight: bold; }
td.empty { text-align: center; color: #aaa; padding: 40px 0; }

/* ---------- 图表 ---------- */
.chart-full { flex: 1; min-height: 300px; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; }
.chart-row { flex: 1; display: flex; gap: 10px; min-height: 300px; }
.chart-half { flex: 1; background: #fff; border: 1px solid #e0e0e0; border-radius: 4px; }

/* ---------- 环境数值卡片 ---------- */
.value-cards { display: flex; gap: 10px; }
.card {
    flex: 0 0 220px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px 16px;
}
.card-name { color: #888; font-size: 13px; }
.card-name small { color: #aaa; }
.card-value {
    font-size: 26px;
    font-weight: bold;
    color: #0066cc;
    font-family: Consolas, monospace;
}

/* ---------- 地图 ---------- */
.map {
    flex: 1;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    position: relative;
}
.map .map-log {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    max-width: 300px;
}
.map .map-log h4 { margin: 0 0 5px; color: #333; border-bottom: 1px solid #ccc; padding-bottom: 5px; }
.map .map-log .entry { margin: 5px 0; color: #666; border-left: 3px solid #007bff; padding-left: 8px; }
.map .map-log .entry .time { font-size: 10px; color: #999; }
.map .map-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    color: #333;
}
.map .map-current {
    position: absolute;
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    color: #007bff;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    white-space: nowrap;
    border: 2px solid #007bff;
}

/* ---------- 历史查询 ---------- */
.history-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: #fff;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}
.history-toolbar input[type="datetime-local"], .history-toolbar select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.history-count { color: #888; font-size: 12px; }

/* ---------- 数据看板 ---------- */
/* ---------- 数据看板 ---------- */
/* 看板铺满视口：#app 占满 100vh，主区 flex:1 吃掉剩余空间，表格/图表随地图同步伸展 */
body.dash-body #app { height: 100vh; display: flex; flex-direction: column; }
.dash-content { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.refresh-hint { color: #999; font-size: 12px; }

.dash-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.dash-retention {
    background: #fff; border: 1px solid #e0e0e0; border-radius: 6px;
    padding: 8px 14px; color: #666; font-size: 12px;
}
.dash-card {
    flex: 1 1 160px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 14px 18px;
}
.dash-card .card-name { color: #888; font-size: 13px; }
.dash-card .card-value { font-size: 30px; font-weight: bold; font-family: Consolas, monospace; }

.dash-main { display: flex; gap: 12px; flex: 1; min-height: 340px; }
.dash-map-wrap { flex: 1.4; display: flex; flex-direction: column; background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; padding: 10px; min-width: 0; }
.dash-map { flex: 1; min-height: 240px; border: 1px solid #eee; border-radius: 4px; }
.dash-table-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dash-table-inner { flex: 1; min-height: 140px; }   /* 高度跟随右列伸展，行多时内部滚动 */
.dash-chart { flex: 0 1 200px; min-height: 150px; background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; }

.panel-title {
    font-size: 13px; font-weight: bold; color: #445;
    padding: 4px 2px 8px;
    display: flex; justify-content: space-between; align-items: center;
}
.panel-title .legend { font-weight: normal; font-size: 12px; color: #888; display: flex; align-items: center; gap: 4px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 2px 0 8px; }
.legend .dot.online { background: #d4f0da; border: 2px solid #2e9e44; }
.legend .dot.offline { background: #eeeeee; border: 2px solid #999; }
.legend .dot.alarm { background: #fff; border: 2px solid #cc3333; }
.legend .dot.poweron { background: #fff; border: 2px solid #b8860b; }

.tag {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 12px; margin-right: 4px;
}
.tag-online { background: #e2f5e6; color: #2e9e44; }
.tag-offline { background: #f0f0f0; color: #999; }
.tag-alarm { background: #fdeaea; color: #cc3333; font-weight: bold; }
.tag-warn { background: #fdf6e3; color: #b8860b; font-weight: bold; }
tr.clickable { cursor: pointer; }

/* ---------- 登录页 ---------- */
.login-body {
    background: linear-gradient(135deg, #1a3c6e 0%, #2c5f9e 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #fff;
    border-radius: 10px;
    padding: 36px 40px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.login-title { font-size: 18px; font-weight: bold; color: #1a3c6e; text-align: center; }
.login-sub { font-size: 13px; color: #999; text-align: center; margin-top: -8px; }
.login-box input {
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    outline: none;
}
.login-box input:focus { border-color: #1a73c6; }
.login-error { color: #cc3333; font-size: 13px; text-align: center; }
.login-btn { padding: 10px; font-size: 15px; }

/* 数据保留配置保存反馈 */
.retention-msg { color: #2e9e44; font-size: 12px; }

/* 设备数据量超限提醒弹窗 */
.modal-mask {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0, 0, 0, 0.45);
    display: flex; align-items: center; justify-content: center;
}
.modal-box {
    background: #fff; border-radius: 8px; padding: 20px 24px;
    width: 420px; max-width: 90vw; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.modal-title { font-size: 16px; font-weight: bold; color: #c0392b; margin-bottom: 10px; }
.modal-body { color: #444; font-size: 14px; line-height: 1.7; }
.modal-body p { margin: 4px 0; }
.size-warn-item { font-weight: bold; color: #1a3c6e; }
.modal-footer { text-align: right; margin-top: 14px; }

/* 后台监听切换开关 */
.switch-label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.switch-label.off { color: #999; }
.switch {
    position: relative; width: 34px; height: 18px; border-radius: 9px;
    background: #ccc; transition: background 0.2s; flex-shrink: 0;
}
.switch.on { background: #2e9e44; }
.switch.disabled { opacity: 0.5; cursor: not-allowed; }
.switch-knob {
    position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
    border-radius: 50%; background: #fff; transition: left 0.2s;
}
.switch.on .switch-knob { left: 18px; }
