/* ============================================================
 * 云卫哨 CloudSentry - 全站样式
 * 适用: index(总览) / history(历史) / alarm(报警) / settings(设置) / about(说明)
 * ============================================================ */
:root {
    --bg: #0d151e;
    --panel: #16222f;
    --panel-2: #1a2836;
    --line: #24384a;
    --line-2: #1c2c3a;
    --text: #e6eef6;
    --text-2: #9db3c6;
    --text-3: #6f8ba0;
    --ok: #3ddc84;
    --warn: #ffb74d;
    --bad: #ff5c5c;
    --info: #4fc3f7;
    --brand: #2f7fd1;
    --r: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 14px;
    -webkit-text-size-adjust: 100%;
}

.page { max-width: 1040px; margin: 0 auto; }

/* ---------------- 页头 ---------------- */
.shell {
    background: linear-gradient(135deg, #16324f, #1d4a6b);
    border-radius: var(--r);
    padding: 14px 18px;
    margin-bottom: 14px;
}
.shell-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
    width: 40px; height: 40px; border-radius: 11px; flex: none;
    background: linear-gradient(135deg, #4fc3f7, #2f7fd1);
    color: #06202f; font-size: 20px; font-weight: bold;
    display: flex; align-items: center; justify-content: center;
}
.brand h1 { font-size: 19px; letter-spacing: .5px; font-weight: 600; }
.sub { font-size: 12px; color: #9fc3dd; margin-top: 3px; }

.status { text-align: right; font-size: 12px; color: #cfe3f1; }
.status .conn { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #607d8b; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--bad); }

.shell nav {
    margin-top: 12px; padding-top: 10px; border-top: 1px solid #2a4258;
    display: flex; gap: 8px; flex-wrap: wrap;
}
.shell nav a {
    text-decoration: none; color: #cfe3f1; font-size: 13px;
    padding: 7px 14px; border-radius: 9px;
    background: rgba(10, 30, 48, .55); border: 1px solid #234058;
    transition: .18s; white-space: nowrap;
}
.shell nav a:hover { background: #1b4568; }
.shell nav a.active { background: #2f7fd1; border-color: #5aa9ee; color: #fff; font-weight: 600; }

/* ---------------- 通用块 ---------------- */
.section { margin-bottom: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 8px; flex-wrap: wrap; }
.section-head > span { display: inline-flex; align-items: center; gap: 6px; }
.section-head h2, .panel-head h2 { font-size: 15px; font-weight: 600; color: #bcd6e8; }

.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r); padding: 15px 16px; margin-bottom: 14px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--text-3); font-weight: normal; }

.grid { display: grid; gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------------- 报警横幅 ---------------- */
.banner {
    display: none; align-items: center; justify-content: space-between; gap: 12px;
    padding: 13px 16px; margin-bottom: 14px; border-radius: var(--r);
    background: linear-gradient(135deg, #b3261e, #7f1d16);
    color: #fff; font-weight: 600; font-size: 15px;
    animation: pulse 1.4s infinite;
}
.banner.show { display: flex; }
.banner .banner-act { flex: none; }
@keyframes pulse { 50% { opacity: .72; } }

/* ---------------- 安全状态总览 ---------------- */
.hero {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: var(--panel); border: 1px solid var(--line);
    border-left: 5px solid var(--text-3);
    border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px;
}
.hero.good { border-left-color: var(--ok); }
.hero.warn { border-left-color: var(--warn); }
.hero.bad  { border-left-color: var(--bad); }
.hero.off  { border-left-color: var(--text-3); }
.hero-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hero-icon {
    width: 46px; height: 46px; border-radius: 50%; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: bold; color: #08131c; background: var(--text-3);
}
.hero.good .hero-icon { background: var(--ok); }
.hero.warn .hero-icon { background: var(--warn); }
.hero.bad  .hero-icon { background: var(--bad); }
.hero-title { font-size: 18px; font-weight: 600; }
.hero-desc { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.hero-side { display: flex; gap: 22px; flex: none; }
.hero-meta span { display: block; font-size: 11px; color: var(--text-3); }
.hero-meta b { font-size: 14px; color: var(--text); font-weight: 600; }

/* ---------------- 核心指标卡 ---------------- */
.metric {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r); padding: 14px 16px;
}
.m-label { font-size: 13px; color: var(--text-2); }
.m-value { display: flex; align-items: baseline; gap: 4px; margin: 6px 0 10px; }
.m-val { font-size: 30px; font-weight: 700; line-height: 1; color: var(--info); }
.m-unit { font-size: 13px; color: var(--text-3); }
.m-bar { height: 6px; background: #0d151e; border-radius: 3px; overflow: hidden; }
.m-bar i { display: block; height: 100%; width: 0; background: var(--info); border-radius: 3px; transition: width .4s; }
.m-note { font-size: 11px; color: var(--text-3); margin-top: 8px; }
.metric.good .m-val { color: var(--ok); } .metric.good .m-bar i { background: var(--ok); }
.metric.warn .m-val { color: var(--warn); } .metric.warn .m-bar i { background: var(--warn); }
.metric.bad  .m-val { color: var(--bad); }  .metric.bad  .m-bar i { background: var(--bad); }

/* ---------------- 次要指标 ---------------- */
.grid-mini { grid-template-columns: repeat(3, 1fr); }
.mini {
    background: var(--panel-2); border: 1px solid var(--line-2);
    border-radius: 11px; padding: 11px 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.mini .mn-label { font-size: 13px; color: var(--text-2); }
.mini .mn-val { font-size: 15px; font-weight: 600; color: var(--text); }
.mini.alert .mn-val { color: var(--bad); }

/* ---------------- 按钮 ---------------- */
.btn {
    padding: 9px 16px; border: none; border-radius: 9px; font-size: 14px;
    cursor: pointer; color: #fff; background: #2b5378; transition: .18s;
    font-family: inherit;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); }
.btn.ok { background: #2e7d32; }
.btn.danger { background: #b3261e; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text-2); }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------------- 设备开关 ---------------- */
.switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.sw-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--panel-2); border: 1px solid var(--line-2);
    border-radius: 11px; padding: 11px 14px;
}
.sw-row .sw-name { font-size: 14px; font-weight: 600; }
.sw-row .sw-desc { display: block; font-size: 11px; color: var(--text-3); font-weight: normal; margin-top: 2px; }
.switch {
    width: 52px; height: 28px; border-radius: 14px; border: none; flex: none;
    background: #3b5064; position: relative; cursor: pointer; transition: .2s; padding: 0;
}
.switch i {
    position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
    border-radius: 50%; background: #dbe6ef; transition: .2s;
}
.switch.on { background: #2e7d32; }
.switch.on i { left: 27px; }
.switch.busy { background: #7a6320; cursor: progress; }
.switch.busy i { background: #ffe0a3; }
.switch:disabled { cursor: progress; }

/* 布防区 */
.arm-box {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: var(--panel-2); border: 1px solid var(--line-2);
    border-radius: 11px; padding: 14px 16px; flex-wrap: wrap;
}
.arm-box .arm-title { font-size: 15px; font-weight: 600; }
.arm-box .arm-desc { display: block; font-size: 12px; color: var(--text-3); font-weight: normal; margin-top: 3px; }
.arm-box.on { border-color: #2e7d32; background: #17291c; }

/* ---------------- 图表 ---------------- */
.chart-box { position: relative; background: #101c27; border-radius: 10px; padding: 6px; }
canvas { display: block; width: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend a {
    text-decoration: none; color: var(--text-2); font-size: 12px;
    display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
}
.legend a i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend a b { color: var(--text); font-weight: 600; }
.legend a.off { opacity: .45; }
.legend a.off b { text-decoration: line-through; }
.legend a.off i { background: #546e7a !important; }
.chart-tip {
    position: absolute; display: none; pointer-events: none;
    background: rgba(8, 18, 26, .95); border: 1px solid #2a4a63;
    border-radius: 8px; padding: 7px 10px; font-size: 12px; color: #cfe3f1;
    min-width: 130px; z-index: 5;
}
.chart-tip b { color: #fff; }
.chart-tip span { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.chart-tip span i { width: 8px; height: 3px; border-radius: 2px; }

/* ---------------- 表格 ---------------- */
.table-wrap { max-height: 420px; overflow: auto; border-radius: 10px; border: 1px solid var(--line-2); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { color: #7fa8c0; font-weight: normal; background: #15212d; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #1d2e3c; }
tbody tr.alarm { background: #33201f; }
tbody tr.alarm:hover { background: #3d2625; }
td.empty, li.empty { text-align: center; color: var(--text-3); padding: 22px 10px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; color: #fff; }
.tag.fire { background: #b3261e; }
.tag.hot { background: #ef6c00; }
.tag.intr { background: #6a1b9a; }
.tag.ok { background: #2e7d32; }
.tag.gray { background: #546e7a; }

/* ---------------- 事件日志 ---------------- */
.log { list-style: none; max-height: 220px; overflow-y: auto; font-size: 12.5px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line-2); color: var(--text-2); }
.log li time { color: var(--text-3); margin-right: 8px; font-family: Consolas, monospace; }
.log li.bad { color: #ff8a80; }
.log li.good { color: #a5d6a7; }
.log li.warn { color: #ffcc80; }

/* ---------------- 表单(设置页) ---------------- */
.form-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.form-row label { width: 168px; color: var(--text-2); font-size: 13.5px; }
.form-row input[type=number] {
    width: 120px; padding: 8px 10px; border-radius: 8px;
    border: 1px solid var(--line); background: #0d151e; color: var(--text);
    font-size: 14px; font-family: inherit;
}
.form-row input[type=number]:focus { outline: none; border-color: var(--brand); }
.form-row .hint { flex: 1; min-width: 160px; }
.readout { display: flex; gap: 26px; flex-wrap: wrap; }
.readout div span { display: block; font-size: 11px; color: var(--text-3); }
.readout div b { font-size: 19px; color: var(--info); font-weight: 700; }
.notice { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.notice.info { background: #13314a; color: #9fd0f0; }
.notice.warn { background: #4a3a13; color: #ffd180; }

/* ---------------- 轻提示 ---------------- */
#toast { position: fixed; left: 0; right: 0; bottom: 22px; z-index: 999;
         display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast-item {
    background: rgba(22, 34, 47, .97); border: 1px solid var(--line);
    border-left: 4px solid var(--info);
    padding: 10px 18px; border-radius: 10px; font-size: 13.5px; color: var(--text);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .4); transition: opacity .4s, transform .4s;
    max-width: 90vw;
}
.toast-item.ok { border-left-color: var(--ok); }
.toast-item.warn { border-left-color: var(--warn); }
.toast-item.bad { border-left-color: var(--bad); }
.toast-item.out { opacity: 0; transform: translateY(8px); }

footer { font-size: 11.5px; color: var(--text-3); text-align: center; padding: 14px 0 6px; line-height: 1.7; }

/* ---------------- 说明页 ---------------- */
.doc p, .doc li { font-size: 13.5px; color: #b7c8d6; line-height: 1.8; }
.doc ul { padding-left: 20px; }
.doc h3 { color: #bcd6e8; font-size: 14px; margin: 14px 0 6px; }
.code {
    background: #101b25; border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 13px; font-family: Consolas, monospace; font-size: 12px;
    color: #9fe0c0; white-space: pre-wrap; margin: 8px 0; line-height: 1.6;
    overflow-x: auto;
}

/* ---------------- 移动端 ---------------- */
@media (max-width: 720px) {
    body { padding: 10px; }
    .shell { padding: 12px 14px; }
    .brand h1 { font-size: 17px; }
    .shell nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .status { text-align: left; width: 100%; }
    .status .conn { justify-content: flex-start; }
    .grid-3, .grid-mini { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .hero { flex-direction: column; align-items: flex-start; }
    .hero-side { gap: 18px; }
    .form-row label { width: 100%; }
    .m-val { font-size: 26px; }
    .table-wrap { max-height: 320px; }
}
