/* 智能家居设备状态实时监控系统 · 深色低多边形设计系统（xa 系列同源） */
:root {
  --bg: #0b1220;
  --bg-soft: #111a2b;
  --panel: rgba(20, 30, 46, 0.90);
  --panel-line: rgba(120, 150, 185, 0.20);
  --ink: #e8f0f8;
  --ink-dim: #9aacc2;
  --ink-faint: #6b7f99;
  --accent: #5eead4;
  --accent-2: #fbbf24;
  --accent-3: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(2, 8, 20, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

.bg-shapes { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.shape { position: absolute; display: block; opacity: 0.5; }
.s1 { width: 480px; height: 480px; left: -140px; top: -160px;
  background: linear-gradient(135deg, rgba(94,234,212,0.15), rgba(94,234,212,0)); clip-path: polygon(0 0, 100% 0, 40% 100%); }
.s2 { width: 520px; height: 520px; right: -180px; top: 8%;
  background: linear-gradient(315deg, rgba(251,191,36,0.12), rgba(251,191,36,0)); clip-path: polygon(100% 0, 100% 100%, 0 30%); }
.s3 { width: 420px; height: 420px; left: 32%; bottom: -200px;
  background: linear-gradient(45deg, rgba(167,139,250,0.12), rgba(167,139,250,0)); clip-path: polygon(30% 0, 100% 100%, 0 100%); }

.app { position: relative; z-index: 1; max-width: 1320px; margin: 0 auto; padding: 18px 22px 0; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 6px 0 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 290px; }
.logo { width: 46px; height: 46px; border-radius: 12px; background: rgba(94,234,212,0.10);
  border: 1px solid rgba(94,234,212,0.32); display: grid; place-items: center; flex: none; }
.logo svg { width: 30px; height: 30px; }
.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: 0.4px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--ink-dim); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tab { background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  padding: 8px 13px; border-radius: 10px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.tab:hover { color: var(--ink); background: rgba(94,234,212,0.08); }
.tab.active { color: #06251f; background: linear-gradient(135deg, var(--accent), #38bdf8); font-weight: 600; }

.top-status { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: rgba(52,211,153,0.13); color: var(--ok); border: 1px solid rgba(52,211,153,0.3); }
.badge.off { background: rgba(251,191,36,0.12); color: var(--warn); border-color: rgba(251,191,36,0.3); }
.badge.soft { background: rgba(96,165,250,0.10); color: #93c5fd; border-color: rgba(96,165,250,0.3); }
.badge.danger { background: rgba(248,113,113,0.12); color: var(--danger); border-color: rgba(248,113,113,0.35); }
.clock { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ---------- 视图 ---------- */
.view { display: none; animation: fadein 0.2s ease; }
.view.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.view-head h2 { margin: 0; font-size: 21px; }
.view-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-dim); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ghost-btn, .primary-btn, .select {
  font-family: inherit; font-size: 13px; padding: 8px 14px; border-radius: 9px; cursor: pointer;
  transition: all 0.15s; border: 1px solid var(--panel-line); background: rgba(255,255,255,0.03); color: var(--ink);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.primary-btn { border-color: transparent; background: linear-gradient(135deg, var(--accent), #38bdf8); color: #06251f; font-weight: 600; }
.primary-btn:hover { filter: brightness(1.08); }
.ghost-btn.small { padding: 4px 10px; font-size: 12px; }
.select { appearance: none; padding-right: 24px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--bg-soft); color: var(--ink); }

/* ---------- 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 2px 0 10px; margin-bottom: 10px; border-bottom: 1px solid rgba(120,150,185,0.12); }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head:not(:first-child) { margin-top: 18px; }
.panel-tip { font-size: 11px; color: var(--ink-faint); }
.empty { color: var(--ink-faint); font-size: 13px; padding: 26px 8px; text-align: center; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
  padding: 14px 16px; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px;
  border-radius: 50%; background: radial-gradient(circle, rgba(94,234,212,0.12), transparent 70%); }
.stat-card .label { font-size: 12px; color: var(--ink-dim); }
.stat-card .num { font-size: 26px; font-weight: 700; line-height: 1.35; font-variant-numeric: tabular-nums; }
.stat-card .unit { font-size: 12px; color: var(--ink-faint); margin-left: 3px; }
.stat-card.green .num { color: var(--ok); }
.stat-card.amber .num { color: var(--warn); }
.stat-card.red .num { color: var(--danger); }
.stat-card.blue .num { color: #7dd3fc; }
.stat-card.purple .num { color: var(--accent-3); }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .dash-cols, .assistant-cols { grid-template-columns: 1fr; } }

/* ---------- 房间 / 排行 ---------- */
.room-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(120,150,185,0.12); }
.room-row:last-child { border-bottom: 0; }
.room-icon { width: 28px; height: 28px; border-radius: 8px; background: rgba(94,234,212,0.10); display: grid; place-items: center; font-size: 15px; }
.room-name { flex: 1; font-size: 13px; }
.room-count { font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.dot-on, .dot-off { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-on { background: var(--ok); }
.dot-off { background: var(--danger); }

.rank-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed rgba(120,150,185,0.12); }
.rank-row:last-child { border-bottom: 0; }
.rank-no { width: 24px; height: 24px; border-radius: 7px; background: rgba(251,191,36,0.14); color: var(--warn);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.rank-name { flex: 1; font-size: 13px; }
.rank-room { font-size: 11px; color: var(--ink-faint); margin-left: 6px; }
.rank-kwh { font-size: 13px; color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* ---------- 柱状图 ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 10px; overflow: hidden; }
.bars.wide { height: 170px; gap: 4px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 22px; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent), rgba(94,234,212,0.25)); transition: height 0.3s; min-height: 2px; }
.bar.high { background: linear-gradient(180deg, var(--accent-2), rgba(251,191,36,0.25)); }
.bar-label { font-size: 9px; color: var(--ink-faint); margin-top: 5px; transform: rotate(-40deg); white-space: nowrap; height: 16px; }

/* ---------- 设备卡 ---------- */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.device-card { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow); }
.device-card.offline { opacity: 0.66; border-style: dashed; }
.dev-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.dev-name { font-size: 14px; font-weight: 600; }
.dev-meta { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.dev-state { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.dev-state.on { background: rgba(52,211,153,0.13); color: var(--ok); }
.dev-state.off { background: rgba(248,113,113,0.12); color: var(--danger); }
.dev-value { font-size: 25px; font-weight: 700; margin: 10px 0 2px; font-variant-numeric: tabular-nums; }
.dev-value .u { font-size: 13px; color: var(--ink-dim); font-weight: 400; }
.dev-info { display: flex; gap: 14px; font-size: 11px; color: var(--ink-faint); flex-wrap: wrap; }
.dev-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(120,150,185,0.12); }
.dev-actions input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.dev-actions input[type=number] { width: 70px; background: rgba(255,255,255,0.04); border: 1px solid var(--panel-line);
  border-radius: 7px; color: var(--ink); padding: 5px 7px; font-family: inherit; font-size: 12px; }
.mini-btn { font-size: 11px; padding: 4px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--panel-line); background: rgba(255,255,255,0.04); color: var(--ink); }
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- 列表 ---------- */
.alert-list, .log-list { max-height: 260px; overflow-y: auto; }
.log-list.tall, .alert-list.tall { max-height: 520px; }
.alert-item { display: flex; gap: 10px; padding: 9px 10px; border-radius: 9px; margin-bottom: 7px;
  background: rgba(255,255,255,0.025); border-left: 3px solid var(--warn); }
.alert-item.danger { border-left-color: var(--danger); }
.alert-item.info { border-left-color: var(--accent-2); }
.alert-item.resolved { opacity: 0.5; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 600; }
.alert-text { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.alert-ts { font-size: 10px; color: var(--ink-faint); margin-top: 3px; }

.log-row { display: flex; gap: 10px; padding: 7px 4px; border-bottom: 1px dashed rgba(120,150,185,0.10); font-size: 12px; }
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--ink-faint); font-variant-numeric: tabular-nums; flex: none; font-size: 11px; }
.log-text { color: var(--ink-dim); flex: 1; min-width: 0; }
.log-tag { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: rgba(94,234,212,0.10); color: var(--accent); flex: none; }
.log-tag.warn { background: rgba(251,191,36,0.12); color: var(--warn); }
.log-tag.danger { background: rgba(248,113,113,0.12); color: var(--danger); }

/* ---------- 规则 ---------- */
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.rule-card { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; padding: 15px 17px; }
.rule-card.disabled { opacity: 0.55; }
.rule-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rule-head h3 { margin: 0; font-size: 14px; }
.rule-line { font-size: 12px; color: var(--ink-dim); margin-top: 9px; }
.rule-line b { color: var(--accent); font-weight: 600; }
.rule-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid rgba(120,150,185,0.12); font-size: 11px; color: var(--ink-faint); }

/* 开关 */
.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: rgba(120,150,185,0.35); border-radius: 999px; cursor: pointer; transition: 0.2s; }
.slider::before { content: ''; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(17px); }

/* ---------- AI ---------- */
.assistant-cols { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 14px; }
.quick-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ai-card { background: rgba(94,234,212,0.045); border: 1px solid rgba(94,234,212,0.18);
  border-radius: 10px; padding: 14px 16px; min-height: 150px; max-height: 300px; overflow-y: auto; }
.ai-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
.ai-card .ai-meta { font-size: 11px; color: var(--ink-faint); margin-bottom: 8px; }
.ai-card pre { margin: 0; font-family: inherit; font-size: 13px; line-height: 1.75; white-space: pre-wrap; color: var(--ink); }

.chat-panel { display: flex; flex-direction: column; }
.chat-box { flex: 1; min-height: 320px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.chat-empty { color: var(--ink-faint); font-size: 12px; text-align: center; padding: 40px 12px; }
.msg { margin-bottom: 12px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 86%; padding: 9px 12px; border-radius: 11px; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.msg.user .bubble { background: linear-gradient(135deg, rgba(94,234,212,0.22), rgba(56,189,248,0.16)); border: 1px solid rgba(94,234,212,0.25); }
.msg.assistant .bubble { background: rgba(255,255,255,0.045); border: 1px solid var(--panel-line); }
.msg .who { font-size: 10px; color: var(--ink-faint); margin-bottom: 3px; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; min-width: 0; background: rgba(255,255,255,0.04); border: 1px solid var(--panel-line);
  border-radius: 9px; padding: 9px 12px; color: var(--ink); font-family: inherit; font-size: 13px; }
.chat-form input:focus { outline: none; border-color: var(--accent); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-dim); }
.field.full { grid-column: 1 / -1; }
.field input, .field textarea { background: rgba(255,255,255,0.04); border: 1px solid var(--panel-line);
  border-radius: 9px; padding: 9px 11px; color: var(--ink); font-family: inherit; font-size: 13px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.tip-box { margin-top: 14px; font-size: 11px; color: var(--ink-faint); background: rgba(94,234,212,0.05);
  border-left: 3px solid var(--accent); padding: 9px 12px; border-radius: 0 8px 8px 0; }

/* ---------- 显著版权条 ---------- */
.copyright-bar {
  margin: 22px -22px 0;
  padding: 0;
  background: linear-gradient(90deg, #d99a12 0%, #f7c956 22%, #ffe39a 50%, #f7c956 78%, #d99a12 100%);
  border-top: 2px solid #ffe9a8;
  box-shadow: 0 -6px 26px rgba(247,201,86,0.18);
}
.copyright-inner {
  max-width: 1320px; margin: 0 auto; padding: 13px 24px;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  color: #2b1b00; font-size: 13px; letter-spacing: 0.3px;
}
.copyright-mark { font-size: 17px; font-weight: 700; }
.copyright-main { font-size: 15px; font-weight: 800; letter-spacing: 1px; text-shadow: 0 1px 0 rgba(255,255,255,0.35); }
.copyright-sep { opacity: 0.5; }
.copyright-sub { font-size: 12px; opacity: 0.86; }
.copyright-version { margin-left: auto; font-size: 11px; opacity: 0.75; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .copyright-inner { justify-content: flex-start; padding: 12px 16px; }
  .copyright-version { margin-left: 0; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120,150,185,0.3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
