* { box-sizing: border-box; }

:root {
  --bg: #f5f3ef;
  --panel: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1a1a1a;
  --primary-hover: #000000;
  --accent: #2563eb;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* Topbar */
.topbar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #eef2ff;
  color: var(--accent);
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

.brand p {
  font-size: 12px;
  margin: 2px 0 0;
  color: var(--muted);
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-block { width: 100%; justify-content: center; padding: 12px; }

.btn-secondary {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn-secondary:hover { background: #e5e7eb; }

.btn-link {
  background: none;
  color: var(--muted);
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
  text-decoration: underline;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }

/* Layout */
.layout {
  position: absolute;
  inset: 0;
}

.map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #f1ede4;
}

.leaflet-container { background: #f1ede4; }

.oblast-tip {
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.oblast-tip:before { display: none; }

.city-label {
  display: flex;
  align-items: center;
  gap: 5px;
  transform: translate(-3px, -3px);
  pointer-events: none;
  user-select: none;
}
.city-dot {
  width: 6px;
  height: 6px;
  background: #1f2937;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  flex-shrink: 0;
}
.city-name {
  font-size: 11px;
  font-weight: 600;
  color: #1f2937;
  text-shadow:
    -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff,
    0 0 4px rgba(255,255,255,0.9);
  white-space: nowrap;
  letter-spacing: 0.1px;
}

/* Sidebar */
.sidebar {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 1000;
  width: 280px;
  max-height: 50vh;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: max-height 0.2s;
}

.sidebar.collapsed {
  max-height: 56px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.sidebar.collapsed .sidebar-header { border-bottom: none; }
.sidebar.collapsed .icon-btn svg { transform: rotate(180deg); }

.member-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.member-item:hover { background: #f9fafb; }

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.member-info { min-width: 0; flex: 1; }
.member-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-loc {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Form panel */
.form-panel {
  position: fixed;
  top: 90px;
  right: 16px;
  bottom: 16px;
  width: 360px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.form-panel[hidden] { display: none; }

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.form-header h2 { font-size: 15px; font-weight: 600; margin: 0; }

.form-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.step { margin-bottom: 22px; }

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e5e7eb;
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field .label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.req { color: #ef4444; }

.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input[type="text"]:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field textarea { resize: vertical; min-height: 60px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.photo-upload {
  display: flex;
  align-items: center;
  gap: 14px;
}

.photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 2px dashed var(--border);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.photo-preview.has-image { border-style: solid; border-color: var(--border); }
.photo-preview.has-image svg { display: none; }

.photo-actions { display: flex; flex-direction: column; gap: 4px; }

/* Leaflet custom marker */
.team-marker {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  background-size: cover;
  background-position: center;
  background-color: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 14px 16px; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content .pop-name { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.leaflet-popup-content .pop-loc { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.leaflet-popup-content .pop-row { margin: 6px 0; }
.leaflet-popup-content .pop-row strong { display: inline-block; min-width: 0; color: var(--muted); font-weight: 500; margin-right: 6px; }
.leaflet-popup-content .pop-photo {
  width: 56px; height: 56px; border-radius: 50%; background-size: cover; background-position: center;
  background-color: #e5e7eb;
  margin-bottom: 8px;
}
.leaflet-popup-content .pop-delete { margin-top: 10px; }

/* Responsive */
@media (max-width: 768px) {
  .form-panel {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: 80vh;
  }
  .sidebar { width: calc(100% - 32px); }
  .topbar { left: 8px; right: 8px; padding: 10px 14px; }
  .brand p { display: none; }
}
