/* Карта объектов: базовые стили каркаса. */
:root {
  --bg: #f6f7f8;
  --text: #1f2933;
  --muted: #6b7785;
  --accent: #2f6fd1;
  --border: #d9dee3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.stub, .error-page { max-width: 560px; margin: 12vh auto; padding: 0 16px; }
.error-code { font-size: 48px; font-weight: 700; color: var(--muted); margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: 6px;
  background: var(--accent); color: #fff; text-decoration: none;
}
.flash-stack { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 10; }
.flash { padding: 8px 16px; border-radius: 6px; background: #fff; border: 1px solid var(--border); }
.flash-err { border-color: #c0392b; }

/* Шапка, формы и таблицы */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 600; color: var(--text); text-decoration: none; }
.topbar-nav { display: flex; gap: 16px; align-items: center; }
.topbar-nav a { color: var(--accent); text-decoration: none; }
.topbar-user { color: var(--muted); }
.inline-form { display: inline; margin: 0; }
.btn-link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.btn-danger { background: #c0392b; }
button.btn { border: 0; cursor: pointer; font: inherit; }
.page { max-width: 880px; margin: 24px auto; padding: 0 16px; }
.auth-card { max-width: 380px; margin: 12vh auto; padding: 24px 16px; }
.field { display: block; margin: 0 0 16px; }
.field > span { display: block; margin-bottom: 4px; font-size: 14px; color: var(--muted); }
.field input[type=text], .field input[type=password], .field select, .field textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
.check { display: block; margin: 0 0 8px; }
.error-text { color: #c0392b; margin: 0 0 16px; }
.notice { padding: 8px 16px; border-radius: 6px; background: #e8f3ea; border: 1px solid #b9dcc0; margin: 0 0 16px; }
.link-box { width: 100%; padding: 8px; font: 14px/1.4 ui-monospace, Consolas, monospace; border: 1px solid var(--border); border-radius: 6px; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---- Карта, список, карточка ---- */
[hidden] { display: none !important; }
a { color: var(--accent); }
.btn-ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
button.btn-ghost { border: 1px solid var(--accent); }
.btn-route { background: var(--accent); }
.btn-disabled { background: #e3e6ea; color: var(--muted); cursor: not-allowed; }
.topbar { flex-wrap: wrap; gap: 4px 12px; min-height: 49px; }
.topbar-nav { flex-wrap: wrap; gap: 4px 14px; }
.topbar-nav a, .topbar-nav .btn-link { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 599px) { .topbar-user { display: none; } }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: #7a7a7a; flex: none; }
.dot-square { border-radius: 2px; background: #555; }
.page-wide { max-width: 1100px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.route { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

body.page-map { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.page-map main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mapwrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mapbar { padding: 8px; background: #fff; border-bottom: 1px solid var(--border); }
.mapbar-q { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.mapbar-filters { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.mapbar-filters select { min-height: 44px; flex: 0 0 auto; max-width: 70vw; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; font: inherit; background: #fff; }
.mapbar-filters .btn { flex: 0 0 auto; }
.mapbody { flex: 1; display: flex; min-height: 0; }
.mapcol { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }
.side { display: none; }
.map-tools { position: absolute; z-index: 500; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 8px; }
.map-count { position: absolute; z-index: 500; left: 8px; bottom: 8px; padding: 4px 10px; background: rgba(255,255,255,.92); border-radius: 6px; font-size: 14px; max-width: calc(100% - 16px); }
.legend { position: absolute; z-index: 500; left: 8px; bottom: 44px; background: rgba(255,255,255,.95); border-radius: 6px; padding: 4px 10px; font-size: 14px; }
.legend summary { cursor: pointer; min-height: 32px; line-height: 32px; }
.legend ul { list-style: none; margin: 0; padding: 0 0 6px; }
.legend li { display: flex; align-items: center; padding: 2px 0; }
.pin-wrap { background: none; border: 0; }
.pin { display: block; width: 22px; height: 22px; margin: 2px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); box-sizing: border-box; }
.pin-mall { border-radius: 4px; }
.sheet { position: absolute; z-index: 600; left: 0; right: 0; bottom: 0; padding: 14px 16px 16px; background: #fff; border-radius: 14px 14px 0 0; box-shadow: 0 -2px 12px rgba(0,0,0,.25); }
.sheet-close { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.sheet-title { display: block; padding-right: 44px; font-size: 17px; }
.sheet-status { display: flex; align-items: baseline; margin-top: 4px; }
.sheet-open .map-count, .sheet-open .legend, .sheet-open .map-tools { display: none; }

.card { max-width: 760px; }
.card-title { margin: 8px 0 4px; font-size: 22px; overflow-wrap: anywhere; }
.card-sub { margin: 0; display: flex; align-items: center; flex-wrap: wrap; }
.fields { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; }
.fields dt { color: var(--muted); font-size: 14px; margin-top: 10px; }
.fields dd { margin: 0 0 4px; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
@media (min-width: 600px) {
  .fields { grid-template-columns: 180px 1fr; }
  .fields dt, .fields dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--border); }
}
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 12px 0; -webkit-overflow-scrolling: touch; }
.gallery-item { flex: 0 0 85%; max-width: 360px; scroll-snap-align: start; }
.gallery-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #e3e6ea; }
.viewer { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-btn { position: absolute; width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255,255,255,.2); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.viewer-close { top: 8px; right: 8px; }
.viewer-prev { left: 8px; top: 50%; }
.viewer-next { right: 8px; top: 50%; }

.filter-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; align-items: end; }
.filter-form .field input, .filter-form .field select { min-height: 44px; width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
.filter-form .field-q { grid-column: 1 / -1; }
.filter-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; min-height: 44px; }
.list-main { display: flex; flex-direction: column; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.list-thumb { flex: none; width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--border); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; line-height: 18px; }
.badge-missing { background: #fdecea; color: #a1281b; border: 1px solid #f3b8b0; align-self: flex-start; }
.field.field-check { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.field.field-check > span { display: inline; margin: 0; }
.list-meta { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; font-size: 14px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 16px 0; gap: 8px; }

@media (min-width: 1024px) {
  .side { display: block; width: 340px; flex: none; overflow-y: auto; background: #fff; border-right: 1px solid var(--border); }
  .side-list { list-style: none; margin: 0; padding: 0; }
  .side-item { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); background: #fff; text-align: left; font: inherit; cursor: pointer; }
  .side-item:hover { background: #f0f4fa; }
  .side-more { padding: 8px 12px; }
  .sheet { left: 12px; right: auto; bottom: 12px; width: 380px; border-radius: 12px; }
  .mapbar { display: flex; gap: 8px; align-items: center; }
  .mapbar-q { max-width: 380px; }
  .mapbar-filters { margin-top: 0; }
}

/* ---- Админка объектов ---- */
.pp-map { height: 320px; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 8px; }
.pp-results { list-style: none; margin: 0 0 8px; padding: 0; }
.pp-item { display: block; width: 100%; text-align: left; margin-bottom: 4px; min-height: 44px; }
.table input[type=text] { padding: 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; max-width: 100%; }

.photo-edit { margin: 8px 0 12px; }
.upload-status { white-space: pre-line; margin: 6px 0 0; }
.photo-list { list-style: none; margin: 0 0 8px; padding: 0; }
.photo-list li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.photo-list img { object-fit: cover; border-radius: 4px; }
.photo-list form.inline { margin: 0; }
