*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 280px;
  --accent: #0078d7;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #ddd;
  --text: #222;
  --text-secondary: #666;
  --danger: #c00;
}

html, body { height: 100%; font-family: system-ui, sans-serif; color: var(--text); background: var(--bg); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.modal {
  background: var(--surface);
  border-radius: 8px;
  padding: 2rem;
  width: min(380px, 90vw);
  display: flex; flex-direction: column; gap: .75rem;
}
.modal h2 { font-size: 1.2rem; }
.modal p  { color: var(--text-secondary); font-size: .9rem; }
.modal input {
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  width: 100%;
}
.modal button {
  padding: .55rem;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 4px;
  font-size: 1rem; cursor: pointer;
}
.modal button:hover { filter: brightness(1.1); }
.error { color: var(--danger); font-size: .85rem; }

/* ── App layout ── */
.app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
}
.sidebar-title { font-weight: 600; font-size: 1rem; }
#btn-logout {
  background: transparent; border: none; color: #fff;
  font-size: 1rem; cursor: pointer; line-height: 1;
}
#device-list-wrap {
  flex: 1; overflow-y: auto; padding: .5rem 0;
}
.hint { padding: .75rem 1rem; color: var(--text-secondary); font-size: .875rem; }

/* Device group */
.device-group { margin-bottom: .25rem; }
.device-toggle {
  width: 100%; text-align: left;
  padding: .55rem 1rem;
  background: none; border: none; cursor: pointer;
  font-size: .8rem; font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .04em;
  display: flex; align-items: center; gap: .4rem;
}
.device-toggle:hover { background: var(--bg); }
.device-toggle .arrow { transition: transform .2s; display: inline-block; }
.device-toggle.open .arrow { transform: rotate(90deg); }

.session-list { list-style: none; }
.session-list li button {
  width: 100%; text-align: left;
  padding: .45rem 1rem .45rem 1.75rem;
  background: none; border: none; cursor: pointer;
  font-size: .875rem; color: var(--text);
}
.session-list li button:hover  { background: var(--bg); }
.session-list li button.active { background: #e3f0fb; color: var(--accent); font-weight: 600; }

/* ── Map ── */
#map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

.map-info {
  position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem 1rem;
  font-size: .875rem;
  pointer-events: none;
  white-space: nowrap;
}
.map-info.hidden { display: none; }
