:root {
  --primary: #1f7a5c;
  --primary-dark: #16573f;
  --bg: #f4f7f5;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --border: #e4e9e7;
  --danger: #d64545;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 122, 92, 0.06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
#app { display: flex; min-height: 100vh; }
#sidebar { width: 220px; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; }
.logo { font-size: 20px; font-weight: 700; padding: 6px 12px 18px; }
.logo span { opacity: .75; font-weight: 400; }
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#nav a { color: rgba(255,255,255,.85); text-decoration: none; padding: 11px 14px; border-radius: 10px; font-size: 14px; transition: background .15s; }
#nav a:hover { background: rgba(255,255,255,.12); }
#nav a.active { background: rgba(255,255,255,.2); font-weight: 600; }
.family-box { background: rgba(255,255,255,.1); border-radius: 12px; padding: 12px; }
.family-box #familyName { font-weight: 600; margin-bottom: 8px; }
#btnFamily { background: rgba(255,255,255,.92); border: 0; color: var(--primary-dark); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; width: 100%; }
#main { flex: 1; padding: 24px; max-width: 1080px; }

h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 17px; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; position: relative; }
.device-card { cursor: pointer; transition: transform .12s; }
.device-card:hover { transform: translateY(-2px); }
.device-card .icon { font-size: 34px; }
.device-card .name { font-weight: 600; margin: 6px 0 2px; }
.device-card .meta { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.online { background: #e3f6ec; color: var(--primary); }
.offline { background: #eceef0; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { justify-content: space-between; }

.btn { background: var(--primary); border: 0; color: #fff; padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }

.control-group { margin: 18px 0; padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.control-group .label { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.switch { width: 50px; height: 28px; border-radius: 20px; background: #d7dde0; position: relative; cursor: pointer; transition: background .18s; flex-shrink: 0; }
.switch.on { background: var(--primary); }
.switch::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on::after { left: 25px; }
input[type=range] { width: 100%; accent-color: var(--primary); }
.value-num { font-size: 22px; font-weight: 700; color: var(--primary); min-width: 74px; text-align: right; }
select, input[type=text] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; width: 100%; }
.ellipsis-btn { background: #f0f3f1; border: 0; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }

.overlay { position: fixed; inset: 0; background: rgba(15,30,24,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.hidden { display: none; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 340px; max-width: 92vw; }
.modal h3 { margin-bottom: 14px; }
.modal input { margin: 8px 0; }
.modal .btn { margin-top: 8px; margin-right: 8px; }
.list-line { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }

.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.timestamp { color: var(--muted); font-size: 12px; }
#topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); background: #232b33; color: #fff; padding: 10px 20px; border-radius: 10px; z-index: 99; opacity: 0; transition: opacity .2s; font-size: 13px; }
#toast.show { opacity: 1; }
.prop-chip { display: inline-flex; align-items: center; gap: 7px; background: #f0f3f1; border-radius: 16px; padding: 4px 12px; font-size: 12px; margin: 3px; }
.prop-chip b { color: var(--primary); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 720px) { #sidebar { width: 66px; } #sidebar .logo, .family-box { display: none; } #nav a { font-size: 0; text-align: center; padding: 12px 0; } }