* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: Arial, sans-serif; color: #17202a; }
button, input, select, textarea { font: inherit; }
button, .button-like { border: 0; background: #1266d6; color: white; border-radius: 9px; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .button-like:hover { background: #0c51af; }
button.danger { background: #c63535; }
button.danger:hover { background: #9e2828; }
.muted, .hint { color: #617083; font-size: 13px; }
.alert { background: #fff0d8; border: 1px solid #ffd28f; border-radius: 10px; padding: 10px 12px; margin: 12px 0; }

.login-body { min-height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, #dbeafe, #f7fafc); }
.login-card { width: min(440px, 92vw); background: white; border-radius: 22px; box-shadow: 0 24px 70px rgba(30,60,120,.18); padding: 32px; }
.brand { color: #1266d6; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }
.login-card h1 { margin: 8px 0 8px; }
.login-form { display: grid; gap: 14px; margin-top: 20px; }
.login-form label { display: grid; gap: 6px; font-weight: 600; }
.login-form input { border: 1px solid #cfd7e2; border-radius: 10px; padding: 11px 12px; }
.login-form button { justify-content: center; padding: 12px; }

.admin-body { background: #f3f7fb; }
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 30px; }
.panel.static-panel { position: static; margin: 16px 0; background: white; border-radius: 16px; padding: 18px; box-shadow: 0 8px 30px rgba(30,60,90,.08); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 12px; align-items: end; }
.grid-form label { display: grid; gap: 5px; }
.grid-form input { border: 1px solid #cfd7e2; border-radius: 9px; padding: 9px 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid #e5e9ef; padding: 8px; text-align: left; }

.map-body { overflow: hidden; }
#map { position: fixed; inset: 0; z-index: 1; background: #cfd8dc; }
.topbar { position: fixed; top: 14px; left: 14px; right: auto; z-index: 1000; width: min(420px, calc(100vw - 28px)); display: grid; gap: 10px; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border: 1px solid rgba(120,140,170,.28); border-radius: 18px; padding: 12px; box-shadow: 0 12px 35px rgba(20,40,80,.18); }
.topbar-brand { display:flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid #e5edf6; padding-bottom: 8px; }
.topbar .title { font-weight: 900; color: #113b76; font-size: 18px; }
.topbar .subtitle { color: #64748b; font-size: 12px; }
.topbar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topbar-actions button, .topbar-actions .button-like { justify-content: center; min-height: 38px; }
.primary-action { background: #0f8a5f; }
.primary-action:hover { background: #0b6f4c; }
.muted-button { background: #64748b; }
.muted-button:hover { background: #475569; }

.panel-title { font-weight: 700; margin-bottom: 6px; }
.small-row { display: flex; gap: 6px; align-items: center; }
.small-row input { flex: 1; }
.small-row button { padding: 6px 9px; }

.drop-overlay { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(18,102,214,.18); border: 4px dashed rgba(18,102,214,.7); align-items: center; justify-content: center; text-align: center; font-size: 26px; color: #0e3c76; font-weight: 800; }
.drop-overlay span { font-size: 16px; font-weight: 400; }
.drop-overlay.visible { display: flex; }

.dialog { border: 0; border-radius: 18px; padding: 0; box-shadow: 0 25px 80px rgba(0,0,0,.25); width: min(560px, 94vw); }
.dialog::backdrop { background: rgba(15,23,42,.28); }
.dialog-body { padding: 20px; display: grid; gap: 12px; }
.dialog-body h2 { margin: 0 0 4px; }
.dialog-body label { display: grid; gap: 5px; font-weight: 650; }
.dialog-body input, .dialog-body select, .dialog-body textarea { border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px 10px; }
.dialog-body label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.list { max-height: 220px; overflow: auto; display: grid; gap: 6px; }
.list-item { border: 1px solid #e3e9f2; border-radius: 10px; padding: 8px; display: grid; gap: 4px; }
.list-item .row { display: flex; justify-content: space-between; gap: 8px; }

.side-panel { position: fixed; right: 14px; top: 14px; bottom: 18px; width: min(390px, 92vw); z-index: 1000; background: rgba(255,255,255,.97); border-radius: 16px; box-shadow: 0 10px 35px rgba(0,0,0,.18); border: 1px solid rgba(120,140,170,.25); display: flex; flex-direction: column; overflow: hidden; }
.side-panel.hidden { display: none; }
.side-head { padding: 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e4eaf2; }
.side-head h2 { margin: 0; font-size: 18px; }
#objectSearch { margin: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px; }
#objectsList { overflow: auto; padding: 0 12px 12px; display: grid; gap: 8px; }
.object-card { border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px; background: white; cursor: pointer; }
.object-card:hover { border-color: #1266d6; }
.object-card .cad { font-weight: 800; color: #123e73; }
.object-card .type { font-size: 12px; color: #64748b; }

.leaflet-popup-content { min-width: 220px; }
.popup-title { font-weight: 800; margin-bottom: 4px; }
.popup-row { font-size: 12px; margin: 2px 0; color: #334155; }
.popup-actions { display: flex; gap: 6px; margin-top: 8px; }
.popup-actions button { padding: 5px 8px; font-size: 12px; }

@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; }
  .topbar .user { display: none; }
}


.yandex-api-leaflet-layer { overflow: hidden; background: #d5dde5; }
.yandex-api-message { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,.94); border: 1px solid #cbd5e1; border-radius: 12px; padding: 12px 16px; color: #334155; font-size: 14px; box-shadow: 0 8px 25px rgba(15,23,42,.18); text-align: center; max-width: 360px; }
.yandex-api-message.error { border-color: #fecaca; color: #991b1b; background: #fff1f2; }

.wide-dialog { width: min(980px, 96vw); }
.preview-toolbar, .object-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 12px 8px; }
.preview-toolbar { padding: 0; }
.preview-list { max-height: 54vh; overflow: auto; display: grid; gap: 6px; border: 1px solid #e2e8f0; border-radius: 12px; padding: 8px; background: #f8fafc; }
.preview-row { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; background: white; font-weight: 400; }
.preview-row input { margin-top: 3px; }
.object-card-head { display: grid; grid-template-columns: 22px 1fr; gap: 7px; align-items: start; }
.object-card-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.object-card-actions button { padding: 5px 7px; font-size: 12px; }
.object-select { width: 16px; height: 16px; }
#selectedObjectsInfo { padding: 0 12px 8px; }

.import-types-fieldset { border: 1px solid #d8e0eb; border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; background: #f8fafc; }
.import-types-fieldset legend { padding: 0 6px; color: #334155; font-weight: 700; font-size: 14px; }

.wms-check-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#wmsLayerSelect { min-height: 40px; }
#wmsPresetNote { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px 10px; }


.admin-crs-form { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.admin-crs-form label { display: grid; gap: 5px; }
.admin-crs-form input, .admin-crs-form select, .admin-crs-form textarea { border: 1px solid #cfd7e2; border-radius: 9px; padding: 9px 10px; }
.admin-crs-form label.check { display:flex; align-items:center; gap:8px; }
.nspd-result-card { border: 1px solid #dbe3ef; border-radius: 10px; padding: 9px; background: white; display:grid; gap:5px; }
.nspd-result-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:4px; }
.nspd-result-actions button { padding: 5px 8px; font-size: 12px; }
.nspd-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nspd-table th, .nspd-table td { border-bottom: 1px solid #e2e8f0; padding: 5px 6px; vertical-align: top; }
.nspd-warning { background:#fff7ed; border:1px solid #fed7aa; border-radius:10px; padding:8px; color:#9a3412; }
@media (max-width: 780px) { .admin-crs-form { grid-template-columns: 1fr; } }

.leaflet-control-layers { margin-top: 12px !important; max-height: calc(100vh - 80px); overflow: auto; border-radius: 12px !important; }
.leaflet-top.leaflet-right { top: 10px; }
.leaflet-top.leaflet-left { top: 150px; }
@media (max-width: 780px) {
  .topbar { left: 8px; right: 8px; width: auto; }
  .topbar-actions { grid-template-columns: 1fr 1fr; }
  .leaflet-top.leaflet-left { top: 185px; }
}
.admin-crs-form .two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-crs-form .two-cols label { display: grid; gap: 5px; }
@media (max-width: 780px) { .admin-crs-form .two-cols { grid-template-columns: 1fr; } }

.button-link {
  display: inline-block;
  margin: 6px 6px 6px 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
}
.nspd-warning pre {
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

/* Админская калибровка пересчета */
.calibration-body { margin: 0; overflow: hidden; font-family: Arial, sans-serif; }
#calibMap { position: fixed; inset: 0; z-index: 1; background: #dbe3ea; }
.calib-panel { position: fixed; z-index: 1000; left: 14px; top: 14px; bottom: 14px; width: min(460px, calc(100vw - 28px)); overflow: auto; background: rgba(255,255,255,.97); border: 1px solid rgba(120,140,170,.35); border-radius: 18px; box-shadow: 0 12px 40px rgba(15,23,42,.22); padding: 16px; display: grid; gap: 12px; }
.calib-head { display: flex; justify-content: space-between; gap: 12px; }
.calib-panel h1 { margin: 0; font-size: 22px; color: #113b76; }
.calib-panel h2 { margin: 4px 0; font-size: 17px; }
.calib-form { display: grid; gap: 10px; }
.calib-form label { display: grid; gap: 5px; font-weight: 650; }
.calib-form label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.calib-form input, .calib-form select { border: 1px solid #cbd5e1; border-radius: 10px; padding: 8px 10px; }
.calib-form fieldset { border: 1px solid #d8e0eb; border-radius: 12px; padding: 10px; display: grid; gap: 8px; background: #f8fafc; }
.calib-form legend { font-weight: 800; color: #334155; }
.calib-move-box { border-top: 1px solid #e5edf6; padding-top: 10px; display: grid; gap: 10px; }
.calib-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.calib-grid2 label { display: grid; gap: 5px; }
.calib-grid2 input { border: 1px solid #cbd5e1; border-radius: 10px; padding: 8px 10px; }
.arrow-pad { display: grid; grid-template-columns: repeat(3, 54px); gap: 7px; justify-content: center; }
.arrow-pad button { height: 44px; justify-content: center; font-size: 20px; }
.calib-readout { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px; font-family: Consolas, monospace; font-size: 13px; }
@media (max-width: 780px) { .calib-panel { right: 8px; left: 8px; width: auto; bottom: auto; max-height: 70vh; } }
.small-table { font-size: 12px; }
.small-table th, .small-table td { padding: 5px 6px; }
button.mini { padding: 4px 8px; border-radius: 8px; font-size: 12px; }
button.danger, .danger-button { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.table-scroll { overflow: auto; max-height: 180px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }

/* Админская ручная поправка X/Y при импорте */
.admin-import-shift-fieldset,
.admin-preview-shift {
  border: 1px solid #f59e0b;
  border-radius: 12px;
  background: #fffbeb;
  padding: 10px;
  margin: 8px 0 12px;
}
.admin-import-shift-fieldset legend,
.shift-title {
  color: #92400e;
  font-weight: 700;
}
.grid-two,
.shift-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px;
  align-items: end;
}
.shift-grid {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}
.shift-arrows {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.shift-arrows button,
.admin-preview-shift button {
  border: 1px solid #d97706;
  background: #fef3c7;
  color: #78350f;
}
.admin-preview-shift input,
.admin-import-shift-fieldset input {
  width: 100%;
}
@media (max-width: 760px) {
  .grid-two,
  .shift-grid {
    grid-template-columns: 1fr;
  }
}


/* === Переписанный админский интерфейс пересчёта и смещений === */
.admin-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.admin-section-head h2 { margin: 0 0 4px; }
.admin-crs-panel { overflow: hidden; }
.admin-crs-form-v2 {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}
.admin-fieldset {
  border: 1px solid #d7e0ec;
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px;
  margin: 0;
}
.admin-fieldset legend {
  padding: 0 8px;
  font-weight: 800;
  color: #123e73;
}
.admin-form-grid {
  display: grid;
  gap: 12px;
  align-items: start;
}
.admin-form-grid.cols-3 { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.admin-form-grid.cols-4 { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.admin-crs-form-v2 label,
.full-width-label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  min-width: 0;
}
.admin-crs-form-v2 input,
.admin-crs-form-v2 select,
.admin-crs-form-v2 textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
}
.admin-crs-form-v2 textarea { resize: vertical; font-family: Consolas, monospace; font-size: 12px; }
.field-help {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.25;
}
.shift-fieldset-clean {
  background: #fffbeb;
  border-color: #f5c66a;
}
.shift-explain {
  background: #fff7d6;
  border: 1px solid #f5d37b;
  border-radius: 10px;
  color: #7a3d00;
  padding: 9px 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.clean-check {
  margin-top: 10px;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600 !important;
}
.admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}
.admin-crs-table-wrap {
  max-height: 420px;
  overflow: auto;
}
.admin-crs-table {
  min-width: 1180px;
  font-size: 12px;
}
.admin-crs-table th {
  position: sticky;
  top: 0;
  background: #eef4fb;
  z-index: 1;
}
.admin-crs-table td { vertical-align: top; }
.admin-crs-table code {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  color: #334155;
}
.proj-cell { max-width: 260px; }
.note-cell {
  margin-top: 4px;
  color: #64748b;
  font-size: 11px;
}
.actions-cell {
  display: grid;
  gap: 6px;
  min-width: 115px;
}
.actions-cell form { margin: 0; }
.actions-cell button { width: 100%; justify-content: center; font-size: 12px; padding: 6px 8px; }

/* Чистый блок ручного смещения импорта */
.clean-import-shift,
.clean-preview-shift {
  border: 1px solid #f2b84b !important;
  background: #fff9e8 !important;
  border-radius: 14px !important;
  padding: 12px !important;
}
.clean-import-shift legend,
.clean-preview-shift .shift-title {
  color: #8a4b00;
  font-weight: 800;
}
.admin-shift-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.admin-shift-inputs label,
.shift-inputs-clean label {
  display: grid;
  gap: 5px;
  font-weight: 700;
  min-width: 0;
}
.admin-shift-inputs input,
.shift-inputs-clean input {
  width: 100%;
  min-width: 0;
  border: 1px solid #d8b35d;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}
.shift-header-clean {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.shift-body-clean {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: end;
}
.shift-inputs-clean {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
}
.shift-buttons-clean {
  display: grid;
  grid-template-columns: repeat(2, 70px);
  gap: 7px;
}
.shift-buttons-clean button,
.clean-preview-shift #previewApplyShift {
  border: 1px solid #d97706;
  background: #fef3c7;
  color: #78350f;
  justify-content: center;
  padding: 7px 9px;
}
.shift-buttons-clean button:hover,
.clean-preview-shift #previewApplyShift:hover {
  background: #fde68a;
}
.shift-note-clean {
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff4cc;
  color: #7a3d00;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 980px) {
  .admin-section-head { display: grid; }
  .admin-form-grid.cols-3,
  .admin-form-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .shift-body-clean { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .admin-wrap { padding: 14px; }
  .admin-form-grid.cols-3,
  .admin-form-grid.cols-4,
  .admin-shift-inputs,
  .shift-inputs-clean { grid-template-columns: 1fr; }
  .shift-header-clean { display: grid; }
  .shift-buttons-clean { grid-template-columns: 1fr 1fr; }
}

/* === Упрощённый блок смещения при загрузке === */
.simple-shift-box {
  display: grid;
  grid-template-columns: auto 120px 120px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  margin: 6px 0 10px;
  border: 1px solid #e6b24d;
  border-radius: 10px;
  background: #fff8e6;
}
.simple-shift-title {
  font-weight: 800;
  color: #8a4b00;
  white-space: nowrap;
  align-self: center;
}
.simple-shift-box label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #653500;
}
.simple-shift-box input {
  width: 100%;
  border: 1px solid #d8b35d;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}
.simple-preview-shift {
  display: grid;
  gap: 8px;
  padding: 8px;
  margin: 6px 0 10px;
  border: 1px solid #e6b24d;
  border-radius: 10px;
  background: #fff8e6;
}
.simple-preview-shift-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #8a4b00;
  font-size: 13px;
}
.simple-preview-shift-head span {
  color: #8a6a28;
  font-size: 12px;
}
.simple-preview-shift-grid {
  display: grid;
  grid-template-columns: 90px 90px 90px repeat(6, auto);
  gap: 6px;
  align-items: end;
}
.simple-preview-shift-grid label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #653500;
}
.simple-preview-shift-grid input {
  width: 100%;
  border: 1px solid #d8b35d;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}
.simple-preview-shift-grid button {
  padding: 7px 10px;
  min-height: 32px;
  border: 1px solid #d97706;
  background: #fef3c7;
  color: #78350f;
  border-radius: 8px;
  justify-content: center;
}
.simple-preview-shift-grid button:hover { background: #fde68a; }
@media (max-width: 900px) {
  .simple-shift-box { grid-template-columns: 1fr 1fr; }
  .simple-shift-title { grid-column: 1 / -1; }
  .simple-preview-shift-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .simple-shift-box,
  .simple-preview-shift-grid { grid-template-columns: 1fr; }
  .simple-preview-shift-head { display: grid; }
}

/* === Оптимизация карты и перечня объектов === */
.map-performance-note {
  max-width: 360px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(148,163,184,.45);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15,23,42,.12);
  color: #334155;
  font-size: 12px;
  line-height: 1.3;
  padding: 7px 9px;
  pointer-events: none;
}

.leaflet-control-layers {
  max-width: min(360px, 90vw);
}
.leaflet-control-layers-list {
  max-height: min(46vh, 420px);
  overflow: auto;
}

.side-panel {
  width: min(760px, 96vw);
  top: 86px;
  right: 10px;
  bottom: 12px;
}
.side-head {
  padding: 10px 12px;
}
.side-head h2 {
  font-size: 17px;
}
#objectSearch {
  margin: 8px 12px;
  padding: 8px 10px;
}
.object-actions {
  gap: 6px;
  padding: 0 12px 6px;
}
.object-actions button {
  padding: 7px 9px;
  font-size: 12px;
}
#selectedObjectsInfo {
  padding: 0 12px 6px;
  font-size: 12px;
}
#objectsList {
  padding: 0 12px 12px;
  overflow: auto;
  display: block;
}
.objects-table-wrap {
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  overflow: auto;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.objects-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  line-height: 1.25;
}
.objects-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef4fb;
  color: #1e3a5f;
  border-bottom: 1px solid #cbd5e1;
  text-align: left;
  font-weight: 800;
  padding: 8px 7px;
  white-space: nowrap;
}
.objects-table tbody td {
  border-bottom: 1px solid #eef2f7;
  padding: 7px;
  vertical-align: middle;
  background: #fff;
}
.objects-table tbody tr:nth-child(even) td {
  background: #fbfdff;
}
.objects-table tbody tr:hover td {
  background: #fff7ed;
}
.objects-table .sel-col {
  width: 28px;
  text-align: center;
}
.objects-table .cad-cell {
  color: #123e73;
  min-width: 138px;
}
.objects-table .num-cell {
  text-align: right;
  white-space: nowrap;
  color: #334155;
}
.objects-table .addr-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #475569;
}
.objects-table .actions-cell {
  min-width: 172px;
  white-space: nowrap;
}
.objects-table .actions-cell button {
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 11px;
  margin-right: 3px;
}
.empty-objects,
.object-limit-note {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px;
  color: #64748b;
}

/* НСПД и спутниковые слои теперь не включаются автоматически: пользователь сам включает нужный слой. */
#wmsPresetNote::after {
  content: ' НСПД не включается автоматически, чтобы карта быстрее открывалась на медленном интернете.';
}

@media (max-width: 900px) {
  .side-panel {
    left: 8px;
    right: 8px;
    width: auto;
    top: 112px;
  }
  .objects-table .addr-cell {
    max-width: 160px;
  }
  .objects-table .actions-cell {
    min-width: 132px;
  }
  .objects-table .actions-cell button {
    padding: 4px 5px;
  }
}

/* === Перемещаемое окно смещения предпросмотра === */
.simple-preview-shift.draggable-shift-panel {
  position: fixed;
  right: 24px;
  top: 96px;
  z-index: 10050;
  width: min(760px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
  user-select: none;
}
.simple-preview-shift.draggable-shift-panel .simple-preview-shift-head {
  cursor: move;
  background: #fef3c7;
  border: 1px solid #f3d48a;
  border-radius: 8px;
  padding: 6px 8px;
  align-items: center;
}
.simple-preview-shift.draggable-shift-panel .simple-preview-shift-head::after {
  content: "перетащить";
  color: #9a6b16;
  font-size: 11px;
  font-weight: 700;
  margin-left: auto;
}
.simple-preview-shift.draggable-shift-panel.is-dragging {
  opacity: 0.94;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.30);
}
@media (max-width: 900px) {
  .simple-preview-shift.draggable-shift-panel {
    left: 12px !important;
    right: auto;
    top: 78px;
    width: calc(100vw - 24px);
  }
}
.ok-text { color: #15803d; font-weight: 700; }
#previewAutoAlignNspd { background: #2563eb; color: #fff; border-color: #1d4ed8; }
#previewAutoAlignNspd:disabled { opacity: .65; cursor: wait; }

.warn-text { color: #b45309; font-weight: 700; }
.muted-text { color: #64748b; font-weight: 600; }

/* Сдвиг только обычной подложки карты/снимков. WMS НСПД не затрагивается. */
.hidden { display: none !important; }
.base-shift-panel {
  position: fixed;
  right: 18px;
  top: 78px;
  width: 285px;
  background: rgba(255,255,255,.97);
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15,23,42,.20);
  z-index: 1800;
  overflow: hidden;
}
.base-shift-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: move;
  background: #f1f5f9;
  border-bottom: 1px solid #dbe4ee;
  padding: 8px 10px;
  user-select: none;
}
.base-shift-head button {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.base-shift-note {
  padding: 8px 10px 0;
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
}
.base-shift-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
  padding: 10px;
}
.base-shift-grid label {
  display: grid;
  gap: 3px;
  font-size: 11px;
  color: #334155;
}
.base-shift-grid input {
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 7px;
}
.base-shift-grid button {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 7px 6px;
  cursor: pointer;
  font-size: 12px;
}
.base-shift-grid #applyBaseShift {
  background: #1266d6;
  border-color: #1266d6;
  color: white;
}
.base-shift-panel.is-dragging {
  opacity: .92;
}

/* === Финальная правка читаемости подписей и кнопок во всех окнах === */
button,
.button-like,
.button-link {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  white-space: normal;
  line-height: 1.18;
  text-align: center;
  justify-content: center;
  align-items: center;
  overflow-wrap: anywhere;
  word-break: normal;
}

button:disabled {
  opacity: 0.65;
}

input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
  line-height: 1.25;
}

.dialog {
  max-height: calc(100vh - 28px);
  overflow: hidden;
}
.dialog-body {
  max-height: calc(100vh - 28px);
  overflow: auto;
}
.dialog-actions {
  flex-wrap: wrap;
  align-items: center;
}
.dialog-actions button,
.dialog-actions .button-like,
.dialog-actions .button-link {
  min-width: 110px;
}

/* Верхняя панель: длинные подписи не налезают друг на друга */
.topbar-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.topbar-actions button,
.topbar-actions .button-like {
  width: 100%;
  padding: 8px 7px;
  min-height: 39px;
  font-size: 13px;
}

/* Панель инструментов предпросмотра: кнопки становятся сеткой, а не давят друг друга */
.preview-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  align-items: stretch;
}
.preview-toolbar button {
  width: 100%;
  min-height: 38px;
  padding: 8px 8px;
  font-size: 13px;
}
#previewAutoAlignNspd {
  grid-column: span 2;
}

/* Простое смещение в окне загрузки */
.simple-shift-box {
  grid-template-columns: minmax(140px, 1fr) minmax(100px, 120px) minmax(100px, 120px) !important;
  align-items: end;
}
.simple-shift-title {
  white-space: normal;
  line-height: 1.2;
}

/* Перемещаемое окно смещения предпросмотра: компактнее и без наложения подписей */
.simple-preview-shift.draggable-shift-panel {
  width: min(560px, calc(100vw - 36px));
  max-height: min(52vh, 360px);
  overflow: auto;
}
.simple-preview-shift-head {
  line-height: 1.2;
}
.simple-preview-shift-head span {
  text-align: right;
}
.simple-preview-shift-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 7px;
  align-items: end;
}
.simple-preview-shift-grid label {
  min-width: 0;
}
.simple-preview-shift-grid button {
  width: 100%;
  min-height: 34px;
  padding: 7px 6px;
  font-size: 12px;
}
#previewApplyShift,
#previewResetShift {
  grid-column: span 1;
}

/* Окно сдвига подложки: закрыть видно, подписи не слипаются */
.base-shift-panel {
  width: min(340px, calc(100vw - 30px));
}
.base-shift-head button,
.side-head > button {
  color: #0f172a;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
}
.base-shift-head button:hover,
.side-head > button:hover {
  background: #cbd5e1;
}
.base-shift-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.base-shift-grid button {
  width: 100%;
  min-height: 33px;
  white-space: nowrap;
}
.base-shift-grid label {
  min-width: 0;
}

/* Панель объектов: кнопки в таблице и сверху не налезают */
.object-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.object-actions button {
  width: 100%;
  min-height: 34px;
  line-height: 1.15;
}
.objects-table .actions-cell {
  white-space: normal;
  min-width: 150px;
}
.objects-table .actions-cell button {
  display: inline-flex;
  width: auto;
  min-width: 56px;
  margin: 2px 2px 2px 0;
  vertical-align: middle;
}

/* Карточки НСПД, WMS и всплывающие окна */
.nspd-result-actions,
.popup-actions,
.object-card-actions,
.wms-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.nspd-result-actions button,
.popup-actions button,
.object-card-actions button,
.wms-check-row button {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

/* Админка: длинные подписи и PROJ4 не ломают строки */
.admin-form-actions,
.admin-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-form-actions button,
.admin-section-actions button,
.admin-form-actions .button-like,
.admin-section-actions .button-like {
  min-width: 130px;
}
.admin-crs-table td,
.admin-crs-table th {
  vertical-align: top;
  overflow-wrap: anywhere;
}
.admin-crs-table button {
  min-height: 31px;
  padding: 6px 8px;
  font-size: 12px;
}

@media (max-width: 760px) {
  .topbar-actions {
    grid-template-columns: 1fr 1fr;
  }
  #previewAutoAlignNspd {
    grid-column: span 1;
  }
  .dialog-actions button,
  .dialog-actions .button-like,
  .dialog-actions .button-link {
    min-width: 0;
    flex: 1 1 130px;
  }
  .simple-shift-box {
    grid-template-columns: 1fr 1fr !important;
  }
  .simple-shift-title {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .topbar-actions,
  .preview-toolbar,
  .object-actions,
  .simple-preview-shift-grid,
  .base-shift-grid {
    grid-template-columns: 1fr;
  }
  .base-shift-panel,
  .simple-preview-shift.draggable-shift-panel {
    left: 10px !important;
    right: auto !important;
    width: calc(100vw - 20px);
  }
  .simple-preview-shift-head {
    display: grid;
    gap: 3px;
  }
  .simple-preview-shift-head span {
    text-align: left;
  }
}

/* === Исправление контраста подписей кнопок: окно сдвига подложки и таблица объектов === */
.base-shift-panel,
.base-shift-panel * {
  color-scheme: light;
}

.base-shift-grid button {
  color: #0f172a !important;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  font-weight: 700;
  text-shadow: none !important;
}

.base-shift-grid button:hover {
  color: #0f172a !important;
  background: #e2e8f0 !important;
}

.base-shift-grid #applyBaseShift {
  color: #ffffff !important;
  background: #1266d6 !important;
  border-color: #1266d6 !important;
}

.base-shift-grid #applyBaseShift:hover {
  color: #ffffff !important;
  background: #0c51af !important;
}

.base-shift-grid #resetBaseShift,
.base-shift-grid button.muted-button {
  color: #ffffff !important;
  background: #64748b !important;
  border-color: #64748b !important;
}

.base-shift-grid #resetBaseShift:hover,
.base-shift-grid button.muted-button:hover {
  color: #ffffff !important;
  background: #475569 !important;
}

.base-shift-head button,
.side-head > button {
  color: #0f172a !important;
  background: #e2e8f0 !important;
  border: 1px solid #cbd5e1 !important;
  text-shadow: none !important;
}

.objects-table .actions-cell button,
.object-card-actions button,
.popup-actions button,
.nspd-result-actions button {
  color: #0f172a !important;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  text-shadow: none !important;
  font-weight: 700;
}

.objects-table .actions-cell button:hover,
.object-card-actions button:hover,
.popup-actions button:hover,
.nspd-result-actions button:hover {
  color: #0f172a !important;
  background: #e2e8f0 !important;
}

.objects-table .actions-cell button.danger,
.object-card-actions button.danger,
.popup-actions button.danger,
.nspd-result-actions button.danger,
.object-actions button.danger {
  color: #991b1b !important;
  background: #fee2e2 !important;
  border-color: #fecaca !important;
}

.objects-table .actions-cell button.danger:hover,
.object-card-actions button.danger:hover,
.popup-actions button.danger:hover,
.nspd-result-actions button.danger:hover,
.object-actions button.danger:hover {
  color: #7f1d1d !important;
  background: #fecaca !important;
}

.object-actions button:not(.danger) {
  color: #ffffff !important;
  background: #1266d6 !important;
  border-color: #1266d6 !important;
}

.object-actions button:not(.danger):hover {
  color: #ffffff !important;
  background: #0c51af !important;
}


/* Страница дополнительных сервисов */
.services-body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #eef6ff 0%, #f8fafc 45%, #eef2ff 100%);
  color: #0f172a;
  font-family: Arial, sans-serif;
}
.services-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
}
.services-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.services-header h1 { margin: 0 0 6px; color: #123e73; }
.services-header p { margin: 0; color: #475569; }
.services-head-actions, .service-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.services-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
}
.service-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  background: rgba(255,255,255,.96);
  border: 1px solid #dbe7f4;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(15,23,42,.08);
  padding: 18px;
}
.service-icon {
  width: 58px; height: 58px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: #e0f2fe;
}
.service-content h2 { margin: 0 0 8px; font-size: 20px; color: #0f3b70; }
.service-content p { margin: 0 0 12px; color: #334155; line-height: 1.45; }
.service-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.service-meta span { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px; padding: 5px 9px; font-size: 13px; color: #334155; }
.ghost-button { background: #e2e8f0 !important; color: #0f172a !important; }
.services-note {
  margin-top: 18px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
}
.services-note h2 { margin: 0 0 8px; color: #123e73; }
.services-note p { margin: 6px 0; color: #334155; }
.services-tab { background: #0ea5e9 !important; }
@media (max-width: 820px) {
  .services-header { flex-direction: column; }
  .services-grid { grid-template-columns: 1fr; }
  .service-card { grid-template-columns: 1fr; }
}


/* === Исправление перекрытия меню и кнопок рисования ===
   Основное меню остается сверху слева, а кнопки масштаба и рисования Leaflet/Draw перенесены вниз слева. */
.leaflet-bottom.leaflet-left {
  bottom: 16px;
}
.leaflet-bottom.leaflet-left .leaflet-control {
  margin-left: 14px;
  margin-bottom: 8px;
}
.leaflet-bottom.leaflet-left .leaflet-draw-toolbar a,
.leaflet-bottom.leaflet-left .leaflet-control-zoom a {
  width: 32px;
  height: 32px;
  line-height: 32px;
}
.leaflet-bottom.leaflet-right {
  bottom: 16px;
  right: 12px;
}
@media (max-width: 780px) {
  .leaflet-bottom.leaflet-left { bottom: 12px; }
  .leaflet-bottom.leaflet-left .leaflet-control { margin-left: 10px; }
  .map-performance-note { display: none; }
}

/* ---- OpenLayers version additions ---- */
.ol-layer-panel {
  position: fixed; right: 12px; top: 78px; z-index: 850; width: 245px;
  background: rgba(255,255,255,.96); border: 1px solid #cfd8dc; border-radius: 10px;
  padding: 0; box-shadow: 0 8px 22px rgba(0,0,0,.16); font-size: 13px;
  max-height: calc(100vh - 150px); overflow: hidden;
}
.ol-layer-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 10px; background:#eef3f8; border-bottom:1px solid #d5dee8; }
.ol-layer-head-title { font-weight:800; color:#102033; }
.ol-layer-toggle { width:28px; height:26px; padding:0 !important; line-height:1; font-size:16px; }
.ol-layer-body { padding: 8px 10px 10px; max-height: calc(100vh - 195px); overflow:auto; }
.ol-layer-panel.collapsed { width: 190px; }
.ol-layer-panel.collapsed .ol-layer-body { display:none; }
.ol-layer-panel.collapsed .ol-layer-head { border-bottom:0; }
.ol-layer-panel label { display: block; padding: 3px 0; color: #1f2937; }
.ol-layer-title { font-weight: 700; margin: 6px 0 4px; color: #0f172a; }
.ol-draw-toolbar {
  position: fixed; left: 12px; bottom: 86px; z-index: 840; display: flex; flex-direction: column; gap: 6px;
  background: rgba(255,255,255,.92); padding: 8px; border: 1px solid #cfd8dc; border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}
.ol-draw-toolbar button, .ol-layer-panel button { color: #102033; background: #f4f7fb; border: 1px solid #b6c2d1; border-radius: 7px; padding: 6px 9px; }
.map-status { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 1200; background: #0f172a; color: #fff; padding: 9px 14px; border-radius: 9px; box-shadow: 0 8px 22px rgba(0,0,0,.25); display: none; max-width: 70vw; }
.map-status.visible { display: block; }
.map-status.error { background: #b91c1c; }
.ol-popup { background: #fff; color: #111827; border: 1px solid #cfd8dc; border-radius: 9px; padding: 8px 10px; min-width: 180px; max-width: 360px; max-height: 70vh; overflow:auto; box-shadow: 0 8px 22px rgba(0,0,0,.18); font-size: 13px; position: relative; }
.ol-popup-close { position: sticky; float:right; top:0; right:0; width:26px; height:26px; border:1px solid #cbd5e1; border-radius:7px; background:#f8fafc; color:#0f172a; font-size:18px; line-height:1; cursor:pointer; z-index:2; margin-left:8px; }
.ol-popup-close:hover { background:#e2e8f0; }
.ol-popup-content { padding-right: 2px; }
.bottom-left-zoom { left: .5em; bottom: .5em; top: auto; }
.ol-control button { color: #111827 !important; background: rgba(255,255,255,.95) !important; }
.ol-scale-line { left: 72px; bottom: 8px; }
.objects-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.objects-table th { position: sticky; top: 0; background: #eef3f8; color:#102033; z-index: 1; }
.objects-table th, .objects-table td { border-bottom: 1px solid #dbe3ea; padding: 6px 7px; vertical-align: top; }
.objects-table tr:hover { background: #f5f8fb; }
.object-table-actions { white-space: nowrap; }
.object-table-actions button { margin: 1px 2px; color:#102033; background:#f4f7fb; border:1px solid #b6c2d1; border-radius:6px; padding:4px 6px; }
.object-table-actions button.danger, button.danger { background:#fee2e2 !important; color:#7f1d1d !important; border-color:#fecaca !important; }
.small { font-size: 12px; }

/* ---- OpenLayers UI fixes: drawing, WMS list, base-shift isolation ---- */
.ol-draw-toolbar {
  min-width: 132px;
  gap: 7px;
  background: rgba(255,255,255,.97);
}
.ol-draw-title {
  font-weight: 800;
  color: #113b76;
  font-size: 13px;
  border-bottom: 1px solid #dbe3ea;
  padding: 0 2px 6px;
  margin-bottom: 2px;
}
.ol-draw-toolbar button {
  width: 100%;
  text-align: center;
  font-weight: 700;
  color: #102033 !important;
  background: #f4f7fb !important;
  border: 1px solid #b6c2d1 !important;
}
.ol-draw-toolbar .draw-primary {
  background: #e8f2ff !important;
  border-color: #93c5fd !important;
  color: #0f3f7a !important;
}
.ol-draw-toolbar.drawing-active {
  border-color: #7b1fa2;
  box-shadow: 0 0 0 3px rgba(123,31,162,.14), 0 8px 22px rgba(0,0,0,.16);
}
.ol-draw-hint {
  max-width: 140px;
  font-size: 11px;
  line-height: 1.25;
  color: #64748b;
}
.ol-layer-panel .muted.small {
  color: #64748b;
  line-height: 1.3;
}
.ol-layer-panel label {
  line-height: 1.25;
  margin-bottom: 2px;
}

/* OpenLayers: корректная Яндекс-подложка через Yandex Maps JS API.
   Она лежит под OpenLayers-векторами, поэтому объекты/WMS не смещаются. */
#map { position: fixed; inset: 0; overflow: hidden; }
.yandex-ol-host {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #d5dde5;
  pointer-events: none;
}
.yandex-ol-host.hidden { display: none; }
#map .ol-viewport { z-index: 1; background: transparent; }
.yandex-ol-message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: rgba(255,255,255,.95);
  color: #334155;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(15,23,42,.18);
}
.yandex-ol-message.error {
  border-color: #fecaca;
  color: #991b1b;
  background: #fff1f2;
}


/* Линейка расстояний */
.ol-draw-toolbar .measure-primary {
  background: #eef6ff !important;
  border-color: #60a5fa !important;
  color: #0f3f7a !important;
}
.ol-draw-toolbar.measure-active {
  border-color: #0f3f7a;
  box-shadow: 0 0 0 3px rgba(15,63,122,.14), 0 8px 22px rgba(0,0,0,.16);
}
.measure-result {
  max-width: 150px;
  padding: 6px 7px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #dbe3ea;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}


/* WMS НСПД ярче: усиливаем контраст и насыщенность тайлов, не трогая пользовательские объекты. */
.ol-nspd-wms-bright canvas {
  filter: contrast(1.55) saturate(1.9) brightness(1.08);
}
.nspd-click-item{border-top:1px solid rgba(0,0,0,.12);margin-top:6px;padding-top:6px;max-width:360px}
#nspdClickMode{height:34px;border-radius:8px;border:1px solid rgba(255,255,255,.25);background:#fff;color:#111;padding:0 8px;max-width:190px}

/* Улучшенный вид переключателя поиска ОКС/участков НСПД */
#nspdClickMode {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  min-width: 185px;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 999px;
  padding: 0 34px 0 14px;
  background: linear-gradient(180deg, #ffffff, #edf4ff);
  color: #12345a;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(15, 63, 122, .18);
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, #12345a 50%),
    linear-gradient(135deg, #12345a 50%, transparent 50%),
    linear-gradient(180deg, #ffffff, #edf4ff);
  background-position:
    calc(100% - 18px) 15px,
    calc(100% - 12px) 15px,
    0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
}
#nspdClickMode:hover {
  border-color: #7fb3ff;
  box-shadow: 0 3px 10px rgba(15, 63, 122, .28);
}
#nspdClickMode:focus {
  outline: 2px solid rgba(21,101,192,.35);
  outline-offset: 2px;
}
.nspd-result-card details,
.nspd-click-item details {
  margin-top: 6px;
}
.nspd-result-card summary,
.nspd-click-item summary {
  cursor: pointer;
  color: #0f3f7a;
  font-weight: 700;
}

/* Основные характеристики НСПД: всегда показываем ключевые поля отдельным блоком. */
.nspd-main-table { margin: 6px 0; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.nspd-main-table th { width: 135px; color: #334155; font-weight: 700; background: #f1f5f9; }
.nspd-main-table td { color: #0f172a; }


/* Компактное меню НСПД: убирает россыпь кнопок из верхней панели. */
.nspd-menu { position: relative; display: inline-flex; align-items: center; }
.nspd-menu-button { min-width: 78px; justify-content: center; font-weight: 700; }
.nspd-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 235px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: rgba(15, 23, 42, .96);
  color: #fff;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(15,23,42,.35);
  z-index: 5000;
}
.nspd-menu-panel.hidden { display: none; }
.nspd-menu-panel button,
.nspd-menu-panel select {
  width: 100%;
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
}
.nspd-menu-panel button {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 650;
  cursor: pointer;
}
.nspd-menu-panel button:hover { background: #e0f2fe; }
.nspd-menu-label { display: grid; gap: 5px; font-size: 12px; color: #cbd5e1; }
.nspd-menu-label select { background: #fff; color: #111827; padding: 0 8px; }
.ol-nspd-wms-labels canvas { image-rendering: auto; }


/* Пользовательские стили объектов */
.object-style-fieldset {
  border: 1px solid #d7e0ec;
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
  background: #f8fafc;
}
.object-style-fieldset legend {
  padding: 0 6px;
  font-weight: 700;
  color: #123e73;
}
.object-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px 12px;
}
.object-style-grid label {
  display: grid;
  gap: 4px;
}
.object-style-grid input,
.object-style-grid select {
  width: 100%;
}
.ol-draw-toolbar.modify-active {
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.18);
}
.ol-draw-toolbar.modify-active #toggleModifyPolygon {
  background: #1565c0;
  color: #fff;
  border-color: #0f4f9e;
}

/* МСК → EPSG:3857 live preview */
.msk-preview-wrap {
  max-width: 1800px;
  width: min(1800px, calc(100vw - 24px));
  padding-left: 12px;
  padding-right: 12px;
}
.msk-preview-grid {
  display: grid;
  grid-template-columns: minmax(480px, 620px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  overflow: visible;
}
.msk-preview-grid > * { min-width: 0; }
.msk-preview-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 5;
  min-width: 0;
}
.msk-preview-form .admin-fieldset {
  min-width: 0;
  overflow: visible;
}
.msk-preview-form input,
.msk-preview-form select,
.msk-preview-form textarea {
  width: 100%;
  min-width: 0;
}
.msk-preview-map-panel {
  position: sticky;
  top: 12px;
  z-index: 1;
  min-width: 0;
  height: min(720px, calc(100vh - 36px));
  min-height: 520px;
  border: 1px solid #d7dde8;
  border-radius: 14px;
  overflow: hidden;
  background: #f3f5f8;
}
.msk-preview-map {
  width: 100%;
  height: 100%;
  min-height: 520px;
}
.inline-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.layer-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 12px; margin-top: 10px; }
.proj4-details { margin-top: 8px; }
.proj4-details code { display: block; white-space: pre-wrap; word-break: break-word; background: #f7f7f7; padding: 8px; border-radius: 8px; }
@media (max-width: 1280px) {
  .msk-preview-grid { grid-template-columns: 1fr; }
  .msk-preview-map-panel {
    position: relative;
    top: auto;
    height: 560px;
    min-height: 560px;
  }
  .msk-preview-map { height: 560px; min-height: 560px; }
}
@media (max-width: 780px) {
  .msk-preview-wrap { width: 100%; padding-left: 10px; padding-right: 10px; }
  .msk-preview-map-panel,
  .msk-preview-map { height: 460px; min-height: 460px; }
  .msk-preview-form .admin-form-grid.cols-3,
  .msk-preview-form .admin-form-grid.cols-4 { grid-template-columns: 1fr; }
  .admin-form-actions { display: grid; grid-template-columns: 1fr; }
}
