/* Стили для формы организации */
.organization-form-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px;
  background: #F8F9FA;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 30px;
  text-align: center;
}

.form-section {
  background: #F7F7F7;
  border-radius: 8px;
  padding: 20px 30px;
  margin-bottom: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.section-titles-row {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  gap: 30px;
  align-items: center;
  margin-bottom: 0;
}

.section-titles-row .section-title {
  margin-bottom: 15px;
}

.section-titles-row .qr-section-title {
  text-align: right;
  grid-column: 3;
}

/* Загрузка логотипа */
.logo-upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.save-btn-inline {
  background: #34AAFF;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(52, 170, 255, 0.2);
  white-space: nowrap;
  width: auto !important;
  min-width: auto !important;
  max-width: none !important;
  height: fit-content;
  margin: 0;
  flex-shrink: 0;
  flex-grow: 0;
  align-self: flex-end;
}

.save-btn-inline:hover {
  background: #0A73BE;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(52, 170, 255, 0.3);
}

.save-btn-inline:active {
  transform: translateY(0);
}

/* Строка названия компании с кнопкой-иконкой сохранения */
.brand-name-row {
  min-width: 0;
  max-width: 100%;
}

.brand-name-row .brand-name-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  resize: none;
  overflow-x: hidden;
  overflow-y: hidden;
  min-height: 38px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

.organization-info .form-group {
  min-width: 0;
  max-width: 100%;
}

.brand-name-save-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  background: transparent;
  color: #D1D5DB;
  cursor: default;
  transition: all 0.2s ease;
}

.brand-name-save-btn.has-changes {
  border-color: #22C55E;
  background: #22C55E;
  color: white;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.35);
  animation: brand-save-pop 0.25s ease;
}

.brand-name-save-btn.has-changes:hover {
  background: #16A34A;
  border-color: #16A34A;
}

@keyframes brand-save-pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.organization-main-info {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  gap: 30px;
  align-items: start;
  position: relative;
}

.organization-main-info .logo-upload-section,
.organization-main-info .qr-code-section {
  align-self: center;
}





.logo-upload-area {
  width: 200px;
  height: 200px;
  border: 2px dashed #D1D5DB;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logo-upload-area:hover {
  border-color: #34AAFF;
  background-color: #f0f8ff;
}

.logo-upload-placeholder {
  text-align: center;
}

.upload-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upload-text {
  font-size: 0.9rem;
  color: #6B7280;
  margin: 0;
}

.logo-upload-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #9CA3AF;
  text-align: center;
  width: 200px;
}

.logo-upload-area.has-logo {
  border-style: solid;
  border-color: #E5E7EB;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.logo-upload-area.has-favicon-fallback {
  position: relative;
  overflow: hidden;
}

.logo-favicon-fallback-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.logo-upload-area.has-favicon-fallback .logo-overlay-text {
  max-width: 168px;
  text-align: center;
  line-height: 1.35;
  font-size: 0.8rem;
}

.logo-upload-area.has-favicon-fallback:hover .logo-upload-overlay,
.logo-upload-area.has-favicon-fallback:focus-visible .logo-upload-overlay {
  opacity: 1;
}

.logo-upload-area.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.logo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.logo-upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.logo-upload-area.has-logo:hover .logo-upload-overlay,
.logo-upload-area.has-logo:focus-visible .logo-upload-overlay {
  opacity: 1;
}

.logo-overlay-text {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

.logo-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.logo-upload-area.has-logo:hover .logo-remove-btn,
.logo-upload-area.has-logo:focus-within .logo-remove-btn {
  opacity: 1;
}

.logo-remove-btn:hover {
  background: rgba(220, 38, 38, 0.9);
}

/* Модальное окно обрезки логотипа (как в Telegram) */
.logo-crop-content {
  max-width: 420px;
}

.logo-crop-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.logo-crop-viewport {
  width: 280px;
  height: 280px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #111827;
  touch-action: none;
  cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.logo-crop-viewport.is-dragging {
  cursor: grabbing;
}

.logo-crop-viewport img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  user-select: none;
  pointer-events: none;
  transform-origin: 0 0;
}

.logo-crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.logo-crop-zoom-icon {
  color: #9CA3AF;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.logo-crop-zoom-slider {
  flex: 1;
  accent-color: #34AAFF;
}

.logo-crop-hint {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #6B7280;
  text-align: center;
}

.logo-crop-footer {
  justify-content: flex-end;
  gap: 12px;
}

/* Основная информация */
.organization-info {
  display: flex;
  flex-direction: column;
  gap: 2px; /* Еще более уменьшен отступ между полями */
  min-width: 0;
  max-width: 100%;
}

.organization-info .phone-email-row {
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
}

.organization-info .form-group-phone,
.organization-info .form-group-email {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}

.phone-group-with-button {
  position: relative;
  display: flex;
  flex-direction: column;
}

.form-group.phone-group-with-button .phone-email-row,
.phone-group-with-button .phone-email-row {
  display: flex !important;
  flex-direction: row !important;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0;
}

.form-group.phone-group-with-button .form-group-phone,
.form-group.phone-group-with-button .form-group-email,
.phone-group-with-button .form-group-phone,
.phone-group-with-button .form-group-email {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}

.phone-group-with-button .save-btn-container-phone {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  margin-top: 12px;
  width: 100%;
}

.phone-group-with-button .save-btn-container-phone input[type="submit"],
.phone-group-with-button .save-btn-container-phone button[type="submit"],
.phone-group-with-button .save-btn-container-phone .save-btn-inline {
  width: auto !important;
  min-width: auto !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  display: inline-block !important;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Переопределяем для phone-email-row */
.form-group.phone-group-with-button > .phone-email-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 20px !important;
  align-items: flex-start !important;
  width: 100% !important;
  margin-bottom: 0 !important;
}

.form-label {
  font-weight: 500;
  color: #374151;
  font-size: 0.95rem;
}

.form-input {
  padding: 12px 16px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 1rem;
  background-color: #FFFFFF;
  transition: border-color 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: #34AAFF;
  box-shadow: 0 0 0 3px rgba(52, 170, 255, 0.1);
  background-color: #FFFFFF;
}

/* Поле телефона использует стандартные стили из .form-input */

/* QR-код */
.qr-code-section {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 0;
  position: relative;
}

.qr-code-display {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: fit-content;
  max-width: 100%;
  gap: 0;
}



.qr-code-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  flex-shrink: 0;
}

.qr-code-mock {
  width: calc(100% - 30px);
  height: calc(100% - 30px);
  max-width: 120px;
  max-height: 120px;
  background: repeating-conic-gradient(
    #000 0% 25%, 
    transparent 0% 50%
  ) 50% / 20% 20%;
  border-radius: 4px;
}

/* Стили для реального QR-кода */
.qr-code-image {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 15px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.qr-code-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.qr-code-text {
  font-size: 0.85rem;
  color: #6B7280;
  margin: 0;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.qr-download-link {
  color: #34AAFF;
  text-decoration: none;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.qr-download-link:hover {
  text-decoration: underline;
}

.qr-download-link-disabled {
  color: #9CA3AF;
  font-weight: 500;
}

/* Модальное окно QR-кода */
.qr-modal-content {
  max-width: 480px;
}

.qr-modal-body {
  padding-top: 8px;
}

.qr-modal-desc {
  margin: 0 0 20px;
  color: #6B7280;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: center;
}

.qr-modal-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  margin-bottom: 24px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
}

.qr-modal-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 8px;
  background: #FFFFFF;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.qr-modal-link-section {
  text-align: left;
}

.qr-modal-link-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.qr-modal-link-input {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  background: #F9FAFB;
  color: #374151;
}

#qrCodeModal .qr-copy-link-btn {
  flex-shrink: 0;
  white-space: nowrap;
  background: transparent;
  border: 1px solid #34AAFF;
  color: #34AAFF;
}

#qrCodeModal .qr-copy-link-btn:hover {
  background: #34AAFF;
  color: white;
  border-color: #34AAFF;
}

#qrCodeModal .qr-copy-link-btn.is-copied {
  border-color: #22C55E;
  color: #16A34A;
  background: #F0FDF4;
}

#qrCodeModal .qr-copy-link-btn.is-copied:hover {
  background: #F0FDF4;
  color: #16A34A;
  border-color: #22C55E;
}

.qr-modal-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #9CA3AF;
}

.qr-modal-section-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
}

.qr-modal-download-section {
  margin-bottom: 24px;
  text-align: left;
}

.qr-download-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qr-download-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
}

.qr-download-option-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.qr-download-format {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
}

.qr-download-note {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #6B7280;
}

#qrCodeModal .qr-download-btn {
  flex-shrink: 0;
  white-space: nowrap;
  background: transparent;
  border: 1px solid #22C55E;
  color: #16A34A;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

#qrCodeModal .qr-download-btn:hover {
  background: #22C55E;
  color: white;
}

.qr-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Секция ссылок */
.links-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.links-buttons {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.prefill-link-btn,
.add-link-btn {
  background: transparent;
  border: 1px solid #34AAFF;
  color: #34AAFF;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.prefill-btn-wrapper .prefill-link-btn {
  width: 100%;
}

.prefill-link-btn:hover,
.add-link-btn:hover {
  background: #34AAFF;
  color: white;
}

.prefill-btn-wrapper {
  display: inline-flex;
  position: relative;
}

/* Активная кнопка "Предзаполнить" — зелёная */
.prefill-link-btn {
  border-color: #22C55E;
  color: #16A34A;
}

.prefill-link-btn:hover {
  background: #22C55E;
  color: white;
}

/* Неактивная кнопка — выглядит как обычная, краснеет контур при наведении */
.prefill-link-btn:disabled {
  border-color: #34AAFF;
  color: #34AAFF;
  background: transparent;
  pointer-events: none;
}

.prefill-btn-wrapper.is-disabled:hover .prefill-link-btn:disabled {
  border-color: #F87171;
}

.prefill-btn-wrapper.is-disabled {
  cursor: not-allowed;
}

/* Мгновенная подсказка при наведении на неактивную кнопку */
.prefill-form-group {
  margin-top: 12px;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.prefill-form-group .brand-name-save-btn {
  flex-shrink: 0;
}

.prefill-form-group .prefill-btn-wrapper {
  width: auto;
  flex: 0 0 auto;
}

.prefill-btn-wrapper.is-disabled::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 280px;
  padding: 10px 12px;
  background: #1F2937;
  color: #F9FAFB;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

/* Стрелка подсказки */
.prefill-btn-wrapper.is-disabled::before {
  content: "";
  position: absolute;
  top: calc(100% + 3px);
  right: 24px;
  z-index: 50;
  border: 5px solid transparent;
  border-bottom-color: #1F2937;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.prefill-btn-wrapper.is-disabled:hover::after,
.prefill-btn-wrapper.is-disabled:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Кнопка "Сохранить" модального окна предзаполнения — контурный стиль,
   зелёная когда доступна */
#prefillLinkModal .modal-footer .btn-primary {
  background: transparent;
  border: 1px solid #22C55E;
  color: #16A34A;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

#prefillLinkModal .modal-footer .btn-primary:hover:not(:disabled) {
  background: #22C55E;
  color: white;
}

#prefillLinkModal .modal-footer .btn-primary:disabled {
  border-color: #34AAFF;
  color: #34AAFF;
}

#prefillLinkModal .modal-footer .btn-primary:disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* Обёртка кнопки "Сохранить" с подсказкой при блокировке */
.prefill-save-wrapper {
  display: inline-flex;
  position: relative;
}

.prefill-save-wrapper.is-disabled {
  cursor: not-allowed;
}

.prefill-save-wrapper.is-disabled::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 260px;
  padding: 10px 12px;
  background: #1F2937;
  color: #F9FAFB;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.prefill-save-wrapper.is-disabled::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  right: 24px;
  z-index: 50;
  border: 5px solid transparent;
  border-top-color: #1F2937;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.prefill-save-wrapper.is-disabled:hover::after,
.prefill-save-wrapper.is-disabled:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.links-table-container {
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  position: relative;
  /* Разрешаем переполнение для выпадающих меню */
  overflow: visible;
}

/* Внутренняя обертка для сохранения закругленных углов */
.links-table-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 8px;
  pointer-events: none;
  z-index: 0;
}

.links-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* Фиксированная раскладка таблицы для контроля ширины колонок */
}

.links-table th {
  background: #F9FAFB;
  padding: 15px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #E5E7EB;
  font-size: 0.9rem;
}

.links-table th:first-child {
  width: 60px;
}

.links-table th:nth-child(2),
.links-table td:nth-child(2) {
  /* Колонка "РЕСУРС" - делаем значительно шире */
  width: 25% !important;
  min-width: 250px;
}

.links-table th:nth-child(3),
.links-table td:nth-child(3) {
  /* Колонка "ОПИСАНИЕ РЕСУРСА" - делаем уже */
  width: 18% !important;
  min-width: 220px;
}

.links-table th:last-child {
  position: relative;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  cursor: help;
}

.info-icon img {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.link-logo-cell {
  text-align: center;
  vertical-align: middle;
}

.link-favicon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  vertical-align: middle;
  object-fit: contain;
  display: inline-block;
}

.link-favicon-fallback {
  font-size: 24px;
  line-height: 32px;
  vertical-align: middle;
}

.prefill-link-favicon-cell {
  min-width: 36px;
}

.prefill-link-favicon {
  display: block;
}

.empty-links-row {
  background: white;
}

.empty-links-message {
  padding: 40px 20px;
  text-align: center;
  color: #9CA3AF;
  font-style: italic;
}

/* Кнопки */
.form-actions {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

/* Адаптивность для формы организации */
@media (max-width: 1024px) {
  .section-titles-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  
  .section-titles-row .qr-section-title {
    text-align: left;
    grid-column: 1;
    margin-top: 0;
  }
  
  .phone-group-with-button .phone-email-row,
  .organization-info .phone-email-row {
    flex-direction: column !important;
    gap: 0;
  }
  
  .save-btn-container-phone {
    margin-top: 10px;
  }
  
  .save-btn-inline {
    width: auto;
  }
  
  .organization-main-info {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .logo-upload-section,
  .qr-code-section {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .organization-form-container {
    padding: 20px;
  }
  
  .form-section {
    padding: 20px;
  }
  
  .links-section-header {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }
  
  .links-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .prefill-form-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .prefill-btn-wrapper {
    width: 100%;
    align-self: stretch;
  }

  .prefill-form-group .brand-name-save-btn {
    width: 100%;
  }

  .prefill-link-btn,
  .add-link-btn {
    width: 100%;
    align-self: stretch;
  }
  
  .links-table th {
    padding: 10px;
    font-size: 0.8rem;
  }
  
  .empty-links-message {
    padding: 30px 15px;
  }

  .qr-modal-link-row {
    flex-direction: column;
  }

  .qr-modal-link-row .qr-copy-link-btn {
    width: 100%;
  }

  .qr-download-option {
    flex-direction: column;
    align-items: stretch;
  }

  .qr-download-option .qr-download-btn {
    width: 100%;
  }

  .qr-modal-footer {
    flex-direction: column-reverse;
  }

  .qr-modal-footer .btn {
    width: 100%;
  }

  .logo-crop-viewport {
    width: min(280px, calc(100vw - 80px));
    height: min(280px, calc(100vw - 80px));
  }

  .logo-crop-zoom-row {
    max-width: min(280px, calc(100vw - 80px));
  }

  .logo-crop-footer {
    flex-direction: column-reverse;
  }

  .logo-crop-footer .btn {
    width: 100%;
  }
}

/* Модальное окно */
.modal {
  display: none;
  position: fixed;
  z-index: 10050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 10051;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 0 24px;
  border-bottom: 1px solid #E5E7EB;
  padding-bottom: 16px;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6B7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background-color: #F3F4F6;
  color: #374151;
}

.modal-body {
  padding: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6B7280;
}

.input-with-icon .form-input {
  padding-left: 40px;
}

.label-with-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.label-with-info span {
  font-weight: 500;
  color: #374151;
  font-size: 0.95rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #E5E7EB;
}

.add-link-form {
  margin: 0;
}

/* Стили для ссылок в таблице */
.link-row {
  background: white;
  cursor: move;
  transition: background-color 0.2s ease;
}

.link-row.dragging {
  opacity: 0.4;
}

.link-row.drag-over {
  border-top: 2px solid #34AAFF;
}

.link-row:hover {
  background-color: #f9fafb;
}

.link-order-cell {
  user-select: none;
}

.resource-link {
  color: #34AAFF;
  text-decoration: none;
  word-break: break-all;
}

.resource-link:hover {
  text-decoration: underline;
}

/* Для ссылок в таблице не показываем фон и рамку, если элемент поддерживает копирование */
.links-table .link-item {
  display: inline;
  padding: 0;
  background: transparent;
  border: none;
  gap: 0;
}

.links-table .link-item:hover {
  background: transparent;
  border: none;
  text-decoration: underline;
}

/* Выпадающее меню действий */
.actions-dropdown {
  position: relative;
  display: inline-block;
  overflow: visible;
}

.actions-trigger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
  position: relative;
  z-index: 1; /* Низкий z-index для кнопки, чтобы не перекрывать открытые меню */
}

.actions-trigger:hover {
  background-color: #f3f4f6;
}

.dots {
  font-size: 18px;
  color: #6B7280;
  line-height: 1;
}

.actions-menu {
  position: absolute !important;
  background: white;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 8px 0;
  min-width: 140px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000; /* Базовый z-index для меню */
  border: 1px solid #E5E7EB;
  top: 100%;
  right: 0;
  margin-top: 5px;
}

/* Для последней строки меню открывается вверх */
.links-table tbody tr:last-child .actions-menu {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 5px;
  transform: translateY(10px);
}

.links-table tbody tr:last-child .actions-menu.show {
  transform: translateY(0);
}

/* Открытое меню должно быть поверх всех элементов таблицы */
.actions-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  z-index: 10000 !important; /* Очень высокий z-index для открытого меню */
}

/* Когда меню открыто, его dropdown контейнер также должен быть выше */
.actions-dropdown .actions-menu.show {
  position: absolute !important;
  z-index: 10000 !important;
}

/* Строки таблицы - базовый z-index */
.links-table tbody tr {
  position: relative;
  z-index: 1;
}

/* Когда меню открыто, строка должна быть выше других строк */
.links-table tbody tr.menu-open {
  z-index: 9999;
  position: relative;
}

/* Альтернатива с :has() для современных браузеров */
.links-table tbody tr:has(.actions-menu.show) {
  z-index: 9999;
  position: relative;
}


.action-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: background-color 0.3s ease;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.action-item:hover {
  background-color: #f8f9fa;
}

.edit-action {
  color: #34AAFF;
}

.delete-action {
  color: #EF4444;
}

/* Колонка действий */
.actions-header {
  width: 80px;
  text-align: center;
}

.actions-cell {
  text-align: center;
  width: 80px;
}

/* Улучшения для таблицы */
.links-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed !important; /* Фиксированная раскладка таблицы для контроля ширины колонок */
}

.links-table th,
.links-table td {
  padding: 16px 20px; /* Увеличиваем отступы */
  border-bottom: 1px solid #E5E7EB; /* Тонкие разделительные линии */
  vertical-align: middle;
}

.links-table th {
  background: #F9FAFB;
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
  border-bottom: 2px solid #E5E7EB; /* Более толстая линия для заголовка */
}

/* Ширина колонок таблицы ссылок */
.links-table th:nth-child(2),
.links-table td:nth-child(2) {
  /* Колонка "РЕСУРС" - делаем еще шире */
  width: 50% !important;
  min-width: 400px !important;
  max-width: none !important;
}

.links-table th:nth-child(3),
.links-table td:nth-child(3) {
  /* Колонка "ОПИСАНИЕ РЕСУРСА" - делаем еще уже */
  width: 15% !important;
  min-width: 100px !important;
  max-width: none !important;
}

.links-table tbody tr:last-child td {
  border-bottom: none; /* Убираем линию у последней строки */
}

.link-row {
  background: white;
  height: 60px; /* Делаем строки шире */
}

.link-row:hover {
  background-color: #f8f9fa;
}

/* Стили для модального окна предзаполнения */
.prefill-resource-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #E5E7EB;
}

.resource-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.resource-input-wrapper .form-input {
  flex: 1;
}

.extract-btn {
  background: #34AAFF;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.extract-btn:hover:not(:disabled) {
  background: #0A73BE;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(52, 170, 255, 0.3);
}

.extract-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.prefill-help-text {
  font-size: 0.875rem;
  color: #6B7280;
  margin-top: 8px;
  line-height: 1.5;
}

.address-modal-content {
  max-width: 700px;
}

/* Адаптивность для модального окна */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 20px;
  }
  
  .modal-footer {
    flex-direction: column;
    gap: 12px;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
  
  .resource-input-wrapper {
    flex-direction: column;
  }
  
  .extract-btn {
    width: 100%;
  }
}

/* Inline-редактирование ссылок организации (как в таблице адресов) */
.links-table .org-link-input {
  width: 100%;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.95rem;
  color: #374151;
  box-sizing: border-box;
}
.links-table .org-link-input:focus {
  outline: none;
  border-color: #34AAFF;
}
.links-table tr.link-row.editing {
  background: #F0F9FF;
}
.links-table .link-edit-save,
.links-table .link-edit-cancel {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.links-table .link-edit-save { color: #10B981; }
.links-table .link-edit-save:hover { background: #ECFDF5; }
.links-table .link-edit-cancel { color: #EF4444; }
.links-table .link-edit-cancel:hover { background: #FEF2F2; }
