* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fff;
  color: #222;
}
body { overflow: hidden; }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #fff;
}
.screen.active { display: flex; }

/* ---------- ЛОГИН ---------- */
#login-screen {
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #c62828 0%, #8e0000 100%);
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 30px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.logo {
  text-align: center;
  color: #c62828;
  font-size: 30px;
  letter-spacing: 2px;
  font-weight: 800;
}
.subtitle { text-align: center; color: #777; margin-bottom: 24px; font-size: 13px; }
.login-box input {
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
}
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 18px; color: #555; }
.error { color: #c62828; margin-top: 10px; text-align: center; font-size: 14px; min-height: 18px; }

/* ---------- КНОПКИ ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: #c62828; color: #fff; margin-bottom: 10px; }
.btn.ghost { background: transparent; color: #c62828; }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.btn.green { background: #2e7d32; color: #fff; }
.btn.orange { background: #ef6c00; color: #fff; }

/* ---------- TOPBAR ---------- */
.topbar {
  height: 52px;
  background: #c62828;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 1000;
}
.topbar .title { flex: 1; text-align: center; font-weight: 600; font-size: 16px; }
.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
}
.icon-btn.dark { color: #333; }

/* ---------- КАРТА ---------- */
#map { flex: 1; z-index: 1; }

.map-buttons {
  position: absolute;
  right: 14px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 900;
}
.fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.fab.blue { background: #1976d2; }
.fab.green { background: #2e7d32; }

/* ---------- DRAWER ---------- */
.drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: #fff;
  box-shadow: 2px 0 16px rgba(0,0,0,0.2);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 1100;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #c62828;
  color: #fff;
  font-weight: 700;
}
.drawer-nav { padding: 8px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 15px;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover { background: #f5f5f5; }
.nav-item.admin-only.hidden { display: none; }

/* ---------- OBJECT CARD ---------- */
.object-card {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  max-height: 55%;
  display: flex;
  flex-direction: column;
  z-index: 900;
}
.object-card.hidden { display: none; }
.object-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  font-weight: 700;
  border-bottom: 1px solid #eee;
}
.object-list { overflow-y: auto; flex: 1; }
.object-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.object-item:hover { background: #fafafa; }
.object-item .info { flex: 1; min-width: 0; }
.object-item .name { font-weight: 600; font-size: 15px; }
.object-item .sub { color: #888; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.object-item .meta { color: #2e7d32; font-size: 13px; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot.grey { background: #bbb; }

/* ---------- CONTENT / SETTINGS / ADMIN ---------- */
.content { flex: 1; overflow-y: auto; padding: 16px; }
.content h2 { font-size: 18px; margin-bottom: 12px; }
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h3 { font-size: 16px; margin-bottom: 12px; }
.card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f2f2f2;
}
.card .row:last-child { border-bottom: none; }
.row-label { color: #555; }
.row-value { font-weight: 600; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f2f2f2;
}
.list-item .l { display: flex; align-items: center; gap: 10px; }
.accent { color: #c62828; }
.divider { height: 8px; }

/* ---------- FULL VIEW (HISTORY) ---------- */
.full-view {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 950;
  display: none;
  flex-direction: column;
}
.full-view.active { display: flex; }
#history-map { flex: 1; }
.history-toolbar { padding: 10px; background: #fff; border-top: 1px solid #eee; display: flex; justify-content: center; }
#history-view.hidden { display: none; }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
}
.modal-box h3 { margin-bottom: 14px; }
.modal-box input, .modal-box select { width: 100%; padding: 11px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 15px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { margin: 0; }
.modal-list { max-height: 260px; overflow-y: auto; margin-bottom: 10px; }
.modal-list label { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }

.leaflet-container { width: 100%; height: 100%; }
.leaflet-popup-content { margin: 8px 10px; }
