:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #185fa5;
  --primary-soft: #e6f1fb;
  --teal: #0f6e56;
  --teal-soft: #e1f5ee;
  --red: #a32d2d;
  --red-soft: #fcebeb;
  --amber: #854f0b;
  --amber-soft: #faeeda;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.6;
}
h1, h2 { margin: 0; font-weight: 500; }
h1 { font-size: 15px; }
h2 { font-size: 14px; margin-bottom: 8px; }
p { margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b4b2a9; }
.dot.ok { background: var(--teal); }
.dot.err { background: var(--red); }
.sub { color: var(--muted); font-size: 12px; }
.auth { display: flex; align-items: center; gap: 8px; }

input, select, button, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); padding: 6px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[type=password] { width: 150px; }
textarea { width: 100%; resize: vertical; min-height: 54px; }
.btn { cursor: pointer; padding: 6px 12px; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--red); }

main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px; }
.map-wrap { position: relative; }
#map { height: 560px; border: 1px solid var(--border); border-radius: 12px; background: #eef1f4; }
.map-hint {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  background: rgba(255,255,255,.94); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; color: var(--muted); font-size: 12px;
}
.side { display: flex; flex-direction: column; gap: 12px; }
.bottom {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px; padding: 0 16px 24px;
}

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; min-width: 0;
}
.desc { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.empty { color: var(--muted); font-size: 12px; padding: 6px 0; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.row:last-child { margin-bottom: 0; }
.row select { flex: 1; min-width: 90px; }
.kv { color: var(--muted); font-size: 12px; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.check input { width: auto; }
.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px; margin-bottom: 8px;
}
.form-grid input, .form-grid select { width: 100%; min-width: 0; }

.device-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 10px; margin-bottom: 8px; cursor: pointer;
}
.device-item:last-child { margin-bottom: 0; }
.device-item.active { border-color: var(--primary); background: var(--primary-soft); }
.device-item .name { font-weight: 500; }
.device-item .meta { color: var(--muted); font-size: 12px; }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; border: 1px solid transparent;
}
.badge.online { color: var(--teal); background: var(--teal-soft); border-color: #9fe1cb; }
.badge.offline { color: var(--red); background: var(--red-soft); border-color: #f7c1c1; }
.badge.high { color: var(--red); background: var(--red-soft); border-color: #f7c1c1; }
.badge.normal { color: var(--primary); background: var(--primary-soft); border-color: #b5d4f4; }
.badge.urgent { color: var(--red); background: var(--red-soft); border-color: #f7c1c1; }

.alert-list { max-height: 200px; overflow: auto; }
.alert {
  border-left: 3px solid var(--border); padding: 6px 0 6px 9px; margin-bottom: 6px;
}
.alert.warn { border-left-color: var(--amber); }
.alert.high { border-left-color: var(--red); }
.alert.info { border-left-color: var(--primary); }
.alert.sos { background: var(--red-soft); border-left-color: var(--red); }
.alert .msg { font-size: 12px; }
.alert .time { color: var(--muted); font-size: 11px; }

.table-wrap { max-height: 220px; overflow: auto; }
.mini-list { max-height: 160px; overflow: auto; margin-top: 8px; }
.msg-item {
  border-top: 1px solid var(--border); padding: 6px 0;
  font-size: 12px; display: flex; gap: 8px; align-items: flex-start;
}
.msg-item .body { flex: 1; min-width: 0; word-break: break-all; }
.msg-item .meta { color: var(--muted); font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td .btn { padding: 2px 8px; font-size: 11px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 11px; }

.badge.ring { color: #7c3aed; background: #f1eafe; border-color: #d9c2fb; }
.bars { color: var(--teal); letter-spacing: 1px; white-space: nowrap; }
.bars-off { color: #d7dbe2; }
.ap-row {
  display: flex; gap: 8px; align-items: center; padding: 3px 0;
  border-top: 1px solid var(--border); font-size: 11px;
}
.ap-row:first-child { border-top: 0; }
.ap-row .ap-ssid {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.verify-text { max-width: 260px; word-break: break-all; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .bottom { grid-template-columns: 1fr; }
  #map { height: 400px; }
}
