/*
 * Базовое оформление широких реестров проекта «Страж».
 * Визуальные параметры перенесены из base-table.css опорного BasePortal,
 * а селекторы изолированы классом .base-table и не меняют остальные таблицы.
 */

.base-table {
  --base-table-text: #071c39;
  --base-table-heading: #536784;
  --base-table-primary: #1f6ed4;
  --base-table-primary-soft: #e7f0ff;
  --base-table-row: #fff;
  --base-table-row-alt: rgb(252, 254, 255);
  --base-table-border: #93c5fd;
  --base-table-hover: rgb(247, 250, 254);
  --base-table-selected: #dbe9fb;
  --table-scale: 1;

  width: 100%;
  min-width: 2200px;
  margin: 0;
  table-layout: auto;
  border-collapse: collapse;
  border-spacing: 0;
  text-indent: initial;
  color: var(--base-table-text);
  font-family: inherit;
  font-size: calc(14px * var(--table-scale));
}

.base-table thead,
.base-table tbody {
  text-align: left;
}

.base-table tbody {
  font-size: inherit;
  font-weight: 400;
}

.base-table th,
.base-table td {
  position: relative;
  box-sizing: border-box;
  width: auto;
  max-width: none;
  border-radius: 0;
  line-height: 1.4;
  vertical-align: middle;
}

.base-table th {
  height: calc(44px * var(--table-scale));
  padding: calc(15px * var(--table-scale)) calc(18px * var(--table-scale));
  border-bottom: 1.5px solid var(--base-table-border);
  background: #dbeafe;
  color: var(--base-table-heading);
  font-size: calc(12px * var(--table-scale));
  font-weight: 600;
  line-height: 1.25;
  text-transform: uppercase;
  white-space: nowrap;
}

.base-table td {
  height: calc(76px * var(--table-scale));
  padding: calc(16px * var(--table-scale)) calc(18px * var(--table-scale));
  border: 0;
  border-bottom: 1.5px solid var(--base-table-border);
  background: var(--base-table-row);
  color: var(--base-table-text);
  font-size: inherit;
  overflow-wrap: normal;
}

.base-table .base-table__sort {
  width: 100%;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: calc(7px * var(--table-scale));
  color: inherit;
  border: 0;
  background: transparent;
  font: inherit;
  line-height: inherit;
  text-align: left;
  text-transform: inherit;
  white-space: inherit;
  cursor: pointer;
}

.base-table .base-table__sort:hover,
.base-table .base-table__sort:focus {
  color: var(--base-table-primary);
  background: transparent;
}

.base-table .base-table__sort:focus-visible {
  outline: 2px solid var(--base-table-primary);
  outline-offset: 3px;
}

.base-table .base-table__sort-icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--base-table-primary);
}

.base-table .base-table__sort-icon svg {
  width: calc(14px * var(--table-scale));
  height: calc(14px * var(--table-scale));
}

.base-table tbody tr:last-child td {
  border-bottom: 0;
}

.base-table tbody tr:nth-child(even) td {
  background: var(--base-table-row-alt);
}

.base-table tbody tr:hover td {
  background: var(--base-table-hover);
}

.base-table tbody tr[data-object-preview-trigger] {
  cursor: pointer;
}

.base-table tbody tr[data-object-preview-trigger]:focus-visible {
  outline: 2px solid var(--base-table-primary);
  outline-offset: -2px;
}

.base-table tbody tr.is-selected td,
.base-table tbody tr.is-selected:hover td {
  background: var(--base-table-selected);
}

.base-table tbody tr.is-selected td:first-child {
  box-shadow: inset 4px 0 0 var(--base-table-primary);
}

.base-table tbody tr.selectedTr > td,
.base-table tbody tr.selectedTr:hover > td {
  background: var(--base-table-selected);
}

.base-table .base-table__badge {
  min-height: 25px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--base-table-primary);
  border: 0;
  border-radius: 14px;
  background: var(--base-table-primary-soft);
  font-size: calc(13px * var(--table-scale));
  font-weight: 600;
  line-height: 1.4;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
}

.base-table [data-display-field="name"] {
  font-weight: 600;
}

.base-table [data-display-field="objectPhone"],
.base-table [data-display-field="customerPhone"] {
  color: var(--base-table-primary);
  font-weight: 500;
}

/* Ширины привязаны к ключам полей и сохраняются после перестановки колонок. */
.base-table th[data-display-field="number"] {
  min-width: 150px;
}

.base-table th[data-display-field="name"] {
  min-width: 220px;
}

.base-table th[data-display-field="address"] {
  min-width: 245px;
}

.base-table th[data-display-field="customer"] {
  min-width: 200px;
}

.base-table th[data-display-field="district"] {
  min-width: 80px;
}

.base-table th[data-display-field="company"] {
  min-width: 180px;
}

.base-table th[data-display-field="headSecurity"] {
  min-width: 190px;
}

.base-table th[data-display-field="responsible"] {
  min-width: 180px;
}

.base-table th[data-display-field="objectPhone"] {
  min-width: 160px;
}

.base-table.stickyTablFix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.base-table-scroll.TableScroll {
  width: 100%;
  max-height: calc(100vh - 260px);
  padding-bottom: 0;
  overflow: auto;
}

.base-table-scroll.TableScroll.objects-table-shell {
  border: 0;
  border-radius: 0;
  background: #fff;
}

/* Таблица и краткая карточка используют тот же двухколоночный сценарий, что реестр персонала. */
.security-object-registry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  align-items: start;
  gap: 16px;
}

.security-object-registry.is-preview-closed {
  grid-template-columns: minmax(0, 1fr);
}

.security-object-registry__table {
  min-width: 0;
}

.security-object-view-switcher .registry-view-switcher-controls {
  gap: 15px;
}

.security-object-view-switcher .registry-view-switcher-controls .uk-button + .uk-button {
  margin-left: 0;
}

/* Карточечное представление показывает только данные, необходимые для быстрого выбора объекта. */
.security-object-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  align-content: start;
  gap: 12px;
}

.security-object-card-grid[hidden] {
  display: none;
}

.security-object-card {
  min-width: 0;
  cursor: pointer;
  border: 1px solid var(--border-color, #dbe5ed);
  border-radius: 9px;
  box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.security-object-card:hover,
.security-object-card:focus-visible {
  border-color: color-mix(in srgb, var(--primary-color, #1e73d8) 55%, var(--border-color, #dbe5ed));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary-color, #1e73d8) 9%, transparent);
  outline: none;
}

.security-object-card.is-selected {
  border-color: var(--primary-color, #1e73d8);
  background: color-mix(in srgb, var(--primary-color, #1e73d8) 4%, var(--surface-color, #fff));
  box-shadow: inset 3px 0 0 var(--primary-color, #1e73d8);
}

.security-object-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.security-object-card__header > strong,
.security-object-card .uk-card-title,
.security-object-card__address,
.security-object-card__facts dd {
  overflow-wrap: anywhere;
}

.security-object-card .uk-card-title {
  color: var(--text-color, #071c39);
  font-size: 1.05rem;
}

.security-object-card__address {
  color: var(--text-color, #071c39);
}

.security-object-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.security-object-card__facts dt {
  color: var(--muted-text-color, #64748b);
  font-size: 0.72rem;
}

.security-object-card__facts dd {
  margin-top: 3px;
  color: var(--text-color, #071c39);
  font-size: 0.84rem;
  font-weight: 600;
}

[data-registry-selected-view="cards"] [data-table-scale-control] {
  display: none;
}

.security-object-preview {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.security-object-preview[hidden],
.security-object-preview__content[hidden] {
  display: none;
}

.security-object-preview__controls {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  gap: 8px;
}

.security-object-preview-settings {
  position: relative;
}

.security-object-preview-settings > summary {
  list-style: none;
}

.security-object-preview-settings > summary::-webkit-details-marker {
  display: none;
}

.security-object-preview-settings[open] > summary {
  border-color: var(--primary-color, #1e73d8);
  background-color: #eef5ff;
  color: var(--primary-color, #1e73d8);
}

.security-object-preview-settings > div {
  position: absolute;
  top: 48px;
  right: -50px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  width: 280px;
  max-width: calc(100vw - 48px);
  max-height: min(480px, calc(100vh - 170px));
  padding: 14px;
  overflow: hidden;
  background: var(--surface-color, #fff);
  border: 1px solid var(--border-color, #dbe5ed);
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.security-object-preview-settings__fields {
  display: grid;
  gap: 9px;
  min-height: 0;
  padding-right: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.security-object-preview-settings label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.security-object-preview__header {
  padding-right: 104px;
}

.security-object-preview__facts {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}

.security-object-preview__facts[hidden] {
  display: none;
}

.security-object-preview__facts > div {
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color, #dbe5ed);
}

.security-object-preview__facts dt {
  color: var(--muted-text-color, #64748b);
  font-size: 0.75rem;
  font-weight: 400;
}

.security-object-preview__facts dd {
  margin: 3px 0 0;
  color: var(--text-color, #071c39);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.security-object-preview__links {
  margin-top: 14px;
}

@media (max-width: 1199px) {
  .security-object-registry,
  .security-object-registry.is-preview-closed {
    grid-template-columns: minmax(0, 1fr);
  }

  .security-object-registry__table {
    grid-row: 2;
  }

  .security-object-registry.is-preview-closed .security-object-registry__table {
    grid-row: 1;
  }

  .security-object-preview {
    position: static;
    grid-row: 1;
    max-height: none;
  }
}

@media (max-width: 639px) {
  .security-object-card__facts {
    grid-template-columns: 1fr;
  }

  .security-object-preview__facts {
    grid-template-columns: 1fr;
  }
}

/* UIkit добавляет таблицам разделители сверху; здесь используется единая нижняя граница строк. */
.base-table.uk-table-divider > :first-child > tr:not(:first-child),
.base-table.uk-table-divider > :not(:first-child) > tr,
.base-table.uk-table-divider > tr:not(:first-child) {
  border-top: 0;
}

@media print {
  .base-table-scroll.TableScroll {
    max-height: none;
    overflow: visible;
  }
}
