:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #6b7785;
  --line: #d7dee7;
  --accent: #1f6feb;
  --accent-hover: #1558c0;
  --danger: #b42318;
  --ok: #067647;
  --dot: #22c55e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 235, 0.12), transparent 40%),
    linear-gradient(160deg, #f7f9fb, #e7edf5 60%, #dde7f2);
}

.login-card,
.modal-card {
  width: min(100%, 380px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 40px rgba(20, 40, 70, 0.08);
}

.login-card h1,
.modal-card h2 {
  margin: 0 0 18px;
}

.users-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 18px;
}

.users-panel-header h2 {
  margin: 0;
  min-width: 0;
}

.users-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.users-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.users-icon-btn:hover {
  background: #f5f8fb;
  border-color: #c5d0dc;
  color: var(--ink);
}

.users-icon-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.users-icon-btn.is-active {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.12);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.12);
}

.users-filter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.users-icon-btn.is-spinning svg {
  animation: users-refresh-spin 0.7s linear;
}

@keyframes users-refresh-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.login-card label,
.modal-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.login-card input,
.modal-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.login-card button,
.map-toolbar button,
.modal-actions button {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.login-card button {
  width: 100%;
  margin-top: 4px;
}

.login-card button:hover,
.map-toolbar button:hover,
.modal-actions button:hover {
  background: var(--accent-hover);
}

.modal-actions button.secondary {
  background: #eef2f6;
  color: var(--ink);
}

.modal-actions button.secondary:hover {
  background: #e2e8f0;
}

.error {
  color: var(--danger);
  margin: 12px 0 0;
  font-size: 14px;
}

.ok {
  color: var(--ok);
  margin: 12px 0 0;
  font-size: 14px;
}

.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.menu-item {
  border: 0;
  background: #eef2f6;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.menu-item:hover {
  background: #d8dee6;
}

.menu-item-right {
  margin-left: auto;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 4fr;
  min-height: 0;
}

.users-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow: auto;
}

.users-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.users-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.users-list li:hover {
  background: #f5f8fb;
  border-color: var(--line);
}

.users-list li.is-selected {
  background: #e8f0fe;
  border-color: #b6ccf5;
}

.users-list li.is-selected:hover {
  background: #dce8fc;
  border-color: #9dbbeb;
}

.users-list .user-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.users-list .online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.users-list .plate {
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: default;
}

.users-list .meta-on-map { color: var(--ok); font-size: 12px;}
.users-list .meta-no-coords { color: var(--danger); font-size: 12px;}

.user-tooltip {
  position: fixed;
  z-index: 40;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.16);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-line;
  pointer-events: none;
}

.user-tooltip[hidden] {
  display: none !important;
}

.map-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.refresh-status {
  color: var(--muted);
  font-size: 14px;
}

.map {
  flex: 1;
  min-height: 420px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 40, 0.35);
  padding: 24px;
  z-index: 20;
}

.modal[hidden],
.app-view[hidden],
.login-view[hidden] {
  display: none !important;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 30vh) 1fr;
  }

  .users-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
