:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1c2230; --line: #2a3140;
  --text: #e6edf3; --muted: #8b98a9; --accent: #e2373b; --ok: #3fb950; --warn: #d29922;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 system-ui, sans-serif;
  background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.link { background: none; border: none; color: var(--muted); cursor: pointer; }
.link:hover { color: var(--text); }

/* login */
.login-screen { display: flex; align-items: center; justify-content: center; height: 100%; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card .sub { margin: 0 0 8px; color: var(--muted); }
.login-card input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); }
.login-card button, .cmds button, header .link { }
.login-card button { padding: 10px; border: none; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer; }
.err { color: var(--accent); min-height: 16px; margin: 0; font-size: 13px; }

/* layout */
header { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel); }
.logo { font-weight: 700; letter-spacing: .3px; }
.tag { font-size: 11px; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 2px 8px; }
.who { color: var(--muted); }
main { display: flex; height: calc(100vh - 49px); }
#roster { width: 280px; border-right: 1px solid var(--line); background: var(--panel);
  overflow-y: auto; }
.roster-head { display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 14px; }
.roster-head h2 { margin: 0; font-size: 15px; }
.counts { font-size: 12px; color: var(--muted); }
#deviceList { list-style: none; margin: 0; padding: 0; }
#deviceList li { padding: 10px 14px; border-top: 1px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; }
#deviceList li:hover, #deviceList li.active { background: var(--panel2); }
.dev-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); }
.dev-sub { font-size: 12px; color: var(--muted); }

#mapWrap { flex: 1; position: relative; }
#map { height: 100%; }

/* GIS address search over the map */
.gis-search { position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; gap: 6px; width: min(520px, 70%); }
.gis-search input { flex: 1; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.gis-search button { padding: 9px 14px; border: none; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer; }
.addr-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
.addr-results div { padding: 8px 12px; cursor: pointer; font-size: 13px; border-top: 1px solid var(--line); }
.addr-results div:first-child { border-top: none; }
.addr-results div:hover { background: var(--panel2); }

/* Overlay toggles + editable datapoint query */
.overlays { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 6px;
  font-size: 12px; color: var(--muted); }
.overlays .ovl-label { color: var(--text); }
.overlays label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.query-row { display: flex; gap: 6px; margin-bottom: 8px; }
.query-row input { flex: 1; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 12px; }
.query-row button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel2); color: var(--text); cursor: pointer; }
.query-row button:hover { border-color: var(--accent); }

/* Monitors list (sidebar) */
#monitorList { list-style: none; margin: 0 0 12px; padding: 0; }
#monitorList li { padding: 9px 14px; border-top: 1px solid var(--line); cursor: pointer; }
#monitorList li:hover { background: var(--panel2); }
.mon-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mon-reasons { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dot.ok { background: var(--ok); }
.dot.alert { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.unknown { background: var(--muted); }
.mon-del { float: right; color: var(--muted); font-size: 12px; }

/* Monitor create form */
.monitor-create { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.monitor-create h3 { margin: 0 0 8px; font-size: 14px; }
.monitor-create input[type=text] { width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); margin-bottom: 8px; }
.monitor-create label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.monitor-create .mini { width: 62px; padding: 3px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.monitor-create button { width: 100%; padding: 8px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--panel2); color: var(--text); cursor: pointer; margin-top: 4px; }
.monitor-create button:hover { background: var(--accent); }

#detail { width: 320px; border-left: 1px solid var(--line); background: var(--panel);
  overflow-y: auto; padding: 14px; position: relative; }
#detail .close { position: absolute; top: 8px; right: 12px; font-size: 20px; }
#detail h2 { margin: 4px 0 8px; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.metric { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.metric .v { font-size: 18px; font-weight: 600; }
.cmds h3 { margin: 8px 0; font-size: 14px; }
.cmds button { display: block; width: 100%; margin-bottom: 6px; padding: 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; }
.cmds button:hover { border-color: var(--accent); }
.cmds button.priv { border-color: var(--warn); }
.priv-note { font-size: 11px; color: var(--warn); margin: 4px 0; }
.cmd-result { font-size: 12px; color: var(--muted); min-height: 16px; }
.sensors { margin-top: 12px; }
.sensor { border-top: 1px solid var(--line); padding: 6px 0; font-size: 13px; }

/* Awareness */
.awareness { margin: 4px 0 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.awx-head { display: flex; align-items: center; justify-content: space-between; }
.awx-head h3 { margin: 0 0 8px; font-size: 14px; }
.radar-toggle { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.awx-status { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.forecast { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0; padding-bottom: 4px; }
.fc { flex: none; width: 58px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 4px; text-align: center; }
.fc .fh { font-size: 10px; color: var(--muted); }
.fc .ft { font-size: 15px; font-weight: 600; margin: 2px 0; }
.fc .fp { font-size: 10px; color: #58a6ff; }
.nearby-wrap { margin-top: 6px; }
.nearby-wrap summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.nearby-item { display: flex; justify-content: space-between; gap: 8px; font-size: 12px;
  border-top: 1px solid var(--line); padding: 5px 0; }
.nearby-item .nk { color: var(--muted); }
.nearby-item .nd { color: var(--muted); white-space: nowrap; }

/* Camera live-view overlay */
.camera-view { position: absolute; inset: 0; z-index: 1000; background: rgba(6,8,12,.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.camera-bar { position: absolute; top: 0; left: 0; right: 0; display: flex;
  justify-content: space-between; align-items: center; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
#camImg { max-width: 92%; max-height: 80%; border-radius: 10px; border: 1px solid var(--line);
  background: #000; min-width: 320px; min-height: 240px; object-fit: contain; }
.cam-hint { position: absolute; bottom: 16px; color: var(--muted); font-size: 12px; }
