* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }

#app { display: flex; height: 100vh; }

#sidebar {
  width: 320px;
  flex: 0 0 320px;
  padding: 16px;
  overflow-y: auto;
  background: #f7f8fa;
  border-right: 1px solid #e3e6eb;
}

#map { flex: 1; height: 100%; }

h1 { font-size: 18px; margin: 0 0 8px; }
h1 .tag {
  font-size: 11px; font-weight: 600; color: #fff; background: #2563eb;
  padding: 2px 6px; border-radius: 6px; vertical-align: middle;
}
h2 { font-size: 14px; margin: 0 0 10px; color: #374151; }
.hint { font-size: 12px; color: #6b7280; line-height: 1.4; margin: 0 0 12px; }

.search { display: flex; gap: 6px; margin-bottom: 14px; }
.search input { flex: 1; padding: 7px 9px; border: 1px solid #cbd2dc; border-radius: 7px; font-size: 13px; }
.search button { padding: 7px 12px; border: none; border-radius: 7px; background: #374151; color: #fff; cursor: pointer; font-size: 13px; }

.rotate {
  background: #fff; border: 1px solid #e3e6eb; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 14px;
}
.rotate label { font-size: 12px; color: #4b5563; margin-bottom: 8px; }
.rotate label span { font-weight: 600; color: #111827; }
.rotate input[type="range"] { width: 100%; margin: 4px 0 8px; }
.rotate button { width: 100%; padding: 7px; border: 1px solid #cbd2dc; border-radius: 7px; background: #fff; cursor: pointer; font-size: 13px; }

.panel {
  background: #fff; border: 1px solid #e3e6eb; border-radius: 10px;
  padding: 14px; margin-bottom: 14px;
}
.hidden { display: none; }

label { display: block; font-size: 12px; color: #4b5563; margin-bottom: 10px; }
label input, label select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
  border: 1px solid #cbd2dc; border-radius: 7px; font-size: 13px; background: #fff;
}

.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.form-actions button { flex: 1; padding: 8px; border: 1px solid #cbd2dc; border-radius: 7px; background: #fff; cursor: pointer; font-size: 13px; }
.form-actions .primary { background: #2563eb; color: #fff; border-color: #2563eb; }

.list-filter {
  width: 100%; padding: 7px 9px; margin-bottom: 10px;
  border: 1px solid #cbd2dc; border-radius: 7px; font-size: 13px;
}
#orgList { font-size: 13px; }
.cat-section { border-bottom: 1px solid #eef0f3; }
.cat-header {
  display: flex; align-items: center; gap: 6px; padding: 9px 4px;
  cursor: pointer; font-weight: 600; color: #374151; user-select: none;
}
.cat-header:hover { color: #111827; }
.cat-arrow { width: 12px; color: #9ca3af; flex: 0 0 12px; }
.cat-title { flex: 1; }
.cat-count {
  background: #eef2ff; color: #4338ca; border-radius: 10px;
  padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.cat-body { padding: 2px 0 6px 18px; }
.org-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.org-item:hover { background: #eef2ff; border-color: #dbe2f5; }
.o-name { font-weight: 600; color: #111827; }
.o-act { color: #6b7280; font-size: 12px; }
.empty { color: #9ca3af; padding: 8px 4px; }
.panel-toggle { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.panel-arrow { color: #9ca3af; font-size: 12px; display: inline-block; width: 12px; }

.dev-banner {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 8px; padding: 9px 11px; font-size: 12.5px; line-height: 1.4;
  margin: 10px 0 4px;
}
.dev-banner a { color: #b45309; font-weight: 600; white-space: nowrap; }
.cat-error { color: #b91c1c; }
.cat-error .cat-count { background: #fee2e2; color: #b91c1c; }
.popup-warn { color: #b91c1c; font-weight: 600; }

/* ---- Клиентский вид ---- */
.tag-soft { background: #0ea5e9; }
.hint a { color: #2563eb; }

/* Подписи павильонов — показываем только при приближении (body.labels-on) */
.leaflet-tooltip.pav-label {
  background: rgba(255, 255, 255, 0.88); border: none; box-shadow: none;
  font-size: 11px; font-weight: 600; color: #1f2937; padding: 1px 5px; display: none;
}
.leaflet-tooltip.pav-label::before { display: none; }
body.labels-on .leaflet-tooltip.pav-label { display: block; }

.back-btn {
  width: 100%; padding: 8px; margin-bottom: 12px; cursor: pointer;
  border: 1px solid #cbd2dc; border-radius: 8px; background: #fff; font-size: 13px; text-align: left;
}
.back-btn:hover { background: #f3f4f6; }

.oc-name { font-size: 17px; font-weight: 700; color: #111827; margin-bottom: 4px; }
.oc-cat {
  display: inline-block; font-size: 12px; color: #4338ca; background: #eef2ff;
  border-radius: 10px; padding: 2px 10px; margin-bottom: 10px;
}
.oc-row { font-size: 14px; color: #374151; margin: 6px 0; }
.oc-row a { color: #2563eb; }
.oc-actions { display: flex; gap: 8px; margin-top: 14px; }
.oc-btn {
  flex: 1; padding: 12px; border: none; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: #fff;
}
.oc-delivery { background: #2563eb; }
.oc-courier { background: #16a34a; }
.oc-btn:hover { filter: brightness(0.95); }
.oc-note {
  margin-top: 12px; padding: 10px; border-radius: 8px; font-size: 13px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; line-height: 1.4;
}

/* ---- Экран входа в админку ---- */
#loginOverlay {
  position: fixed; inset: 0; z-index: 2000; display: flex;
  align-items: center; justify-content: center; background: #16263f;
}
.login-box {
  background: #fff; border-radius: 14px; padding: 28px; width: 300px; text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.login-box h2 { margin: 0 0 4px; font-size: 18px; }
.login-box p { margin: 0 0 16px; color: #6b7280; font-size: 13px; }
.login-box input {
  width: 100%; padding: 10px; border: 1px solid #cbd2dc; border-radius: 8px;
  font-size: 14px; margin-bottom: 12px;
}
.login-box button {
  width: 100%; padding: 10px; border: none; border-radius: 8px;
  background: #ff6d00; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-err { color: #b91c1c; font-size: 13px; margin-top: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.login-top {
  font-size: 13px; font-weight: 600; color: #fff; background: #16263f;
  text-decoration: none; padding: 6px 14px; border-radius: 8px; white-space: nowrap;
}
.login-top:hover { background: #243a5e; }
.login-back {
  display: inline-block; margin-top: 14px; font-size: 13px;
  color: #6b7280; text-decoration: none;
}
.login-back:hover { color: #2563eb; }

/* ---- Мобильная вёрстка: панель сверху компактная, карта снизу большая ---- */
@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar {
    width: auto; flex: 0 0 auto; max-height: 42vh;
    border-right: none; border-bottom: 1px solid #e3e6eb;
  }
  #map { flex: 1 1 auto; min-height: 58vh; }
  h1 { font-size: 16px; }
  .hint { display: none; }
}

/* Попапы */
.popup-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.popup-row { font-size: 12px; color: #4b5563; margin: 2px 0; }
.popup-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.popup-actions button { flex: 1 1 auto; padding: 5px 8px; border: 1px solid #cbd2dc; border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; white-space: nowrap; }
.popup-actions .js-del { color: #b91c1c; border-color: #f0c0c0; }
