:root {
  --bg: #f4f5f7; --panel: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --live: #2563eb; --stale: #9ca3af; --offline: #ef4444; --accent: #111827;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column;
}
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 6px 12px; color: var(--text); }
button:hover { background: #f3f4f6; }

/* шапка */
.top { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 17px; margin: 0; }
.status { color: var(--muted); font-size: 13px; margin-left: auto; }
.status.err { color: var(--offline); }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); font-size: 13px; }

/* основа: список слева, карта справа */
.app { flex: 1; display: flex; min-height: 0; }
.side { width: 300px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.devices { list-style: none; margin: 0; padding: 6px 0; overflow: auto; flex: 1; }
.devices .empty { padding: 14px; color: var(--muted); font-size: 14px; }
.dev { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; border-left: 3px solid transparent; }
.dev:hover { background: #f9fafb; }
.dev.active { border-left-color: var(--accent); background: #f3f4f6; }
.pin-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--live); flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line); }
.dev.stale .pin-dot { background: var(--stale); }
.dev.offline .pin-dot { background: var(--stale); outline: 2px solid var(--offline); outline-offset: -3px; }
.dev-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dev-name { font-weight: 600; }
.dev-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dev.stale .dev-ago, .dev.offline .dev-ago { color: var(--offline); }
.map { flex: 1; min-width: 0; }

/* маркер: кружок с Tracker ID */
.pin { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--live); color: #fff; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pin.stale, .pin.offline { background: var(--stale); }
.pin.offline { border-color: var(--offline); }
.leaflet-popup-content { margin: 10px 14px; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content b { font-size: 14px; }

/* телефон: список под картой */
@media (max-width: 720px) {
  .app { flex-direction: column-reverse; }
  .side { width: auto; max-height: 38vh; border-right: 0; border-top: 1px solid var(--line); }
  .top { padding: 8px 10px; }
  .who { display: none; }
}

/* страница входа */
body.login { align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.card input { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.card button { background: var(--accent); color: #fff; border-color: var(--accent); padding: 10px; }
.card .err { margin: 0; color: var(--offline); font-size: 14px; }
.leaflet-container:focus { outline: none; }
